How do I print the "id" attribute of Item?
-
Good day!
How to print "id" attribute?
I want to trace focus. Now I forced to use "objectName" property, but I want to print "id" directly.
[code]
Window {
visible: trueonActiveFocusItemChanged: { var fitem = activeFocusItem if (fitem) do console.log(fitem.objectName) while (fitem = fitem.parent) else console.log("no focus") }
}
[/code]How to print the "id" attribute?
Best regards.
-
Printing the item using its id (rather than the id property of the item) works. If the objectName property is defined, that will also be output. For example:
@
Item {
id: myItem
objectName: "my item"
Component.onCompleted: print(myItem)
}
@should result in something along the lines of:
qml: QQuickItem(0x101e12c60, "my item")edit: The same applies for properties or variables assigned the value of the item using its id