Trouble with anchors

  • I am attempting to create a text box which will display the value the user is entering inside of the keyboard:

            id: idFlowDigitsEntryBox
            width: (keyWidth * 3 + keySpacing * 2) * 2
            height: 50
            anchors.leftMargin: keySpacing
            spacing: keySpacing
                id: display
                color: "white"
                width: parent.width
                height: keyHeight
                radius: 5
                Text //<- error's on this line
                    id: entryDisplay
                    width: parent.width - 50
                    anchors.centerIn: idFlowDigitsEntryBox
                    color: "black"


    QML QQuickText: Cannot anchor to an item that isn't a parent or sibling.

    Why am I getting this error, any ideas?

  • Moderators

    The error message is clear - you should anchor to parent, not grand parent. Change your code to:

    anchors.centerIn: parent

    And the error will go away.

  • @sierdzio Thanks!

Log in to reply