⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

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.

    Window {
    visible: true

    onActiveFocusItemChanged: {
        var fitem = activeFocusItem
        if (fitem)
            while (fitem = fitem.parent)
            console.log("no focus")


    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

Log in to reply