diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2017-05-02 20:04:48 +0200 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2021-09-17 06:42:28 +0000 |
commit | 0a3270f2da393bbb375145e37a207ff83c266b4b (patch) | |
tree | ecaef57202897432cb482c6878375758b8d69cac /src/quick/items/qquickitem_p.h | |
parent | d8b5d90baf7d3638d3d1114d6ca0acdd51437c47 (diff) |
Add invokable QQuickItem::dumpItemTree()
It's possible to do something like this in JS code with a for loop (and
now we have docs explaining how!); but it can also be handy to do it
from C++ code, including in autotests. It simply uses the QQuickItem
debug operator, recursively, with indentation to show the nesting.
Similar to QObject::dumpObjectTree(), but the item tree can be
different.
Output from one of the repeater autotests now looks like this (only when
the qt.quick.tests logging category is enabled):
=== item tree:
QQuickRootItem(0x55bcd3e45770)
QQuickRectangle_QML_0(0x55bcd3e70bc0)
QQuickColumn(0x55bcd3e710d0, name = container)
QQuickRectangle(0x55bcd3e71450, name = item1)
QQuickText(0x7f35d800cc80, name = text1)
QQuickRectangle(0x55bcd3e74020, name = item2)
QQuickText(0x55bcd3e743a0, name = text2)
QQuickRectangle(0x55bcd3e7c250, name = item3)
QQuickText(0x55bcd3e7c620, name = text3)
QQuickRepeater(0x55bcd3e7f160, name = repeater)
=== object tree:
QQuickView::
QQuickRootItem::
QQuickDeliveryAgent::
QQuickRectangle_QML_0::
QQmlObjectModel::itemModel1
QQuickRectangle::item1
QQuickText::text1
QQmlObjectModelAttached::
QQuickRectangle::item2
QQuickText::text2
QQmlObjectModelAttached::
QQuickRectangle::item3
QQuickText::text3
QQmlObjectModelAttached::
QQmlObjectModel::itemModel2
QQuickRectangle::item4
QQuickText::text4
QQmlObjectModelAttached::
QQuickRectangle::item5
QQuickText::text5
QQmlObjectModelAttached::
QQuickColumn::container
QQuickRepeater::repeater
QQmlEngine::
QQuickFontValueType::
QQmlComponent::
which shows that Repeater normally reparents the items that it creates
to _its_ parent, but these items have QQmlObjectModels as their
QObject parents because of being declared that way.
[ChangeLog][QtQuick][QQuickItem] dumpItemTree() has been added; it
can be called from C++ (similar to QObject::dumpObjectTree()) or
from QML, to show the qDebug-operator output for an item and all
its children, indented to show the tree structure.
Task-number: QTBUG-66771
Change-Id: I70410b19610b621fd1bb35d00575d7001efa6580
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quick/items/qquickitem_p.h')
-rw-r--r-- | src/quick/items/qquickitem_p.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index d8a7c1dfdc..f55c655723 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -687,6 +687,7 @@ public: #endif virtual void updatePolish() { } + virtual void dumpItemTree(int indent) const; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QQuickItemPrivate::ExtraDataTags) |