Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Trouble with anchors
Qt 6.11 is out! See what's new in the release blog

Trouble with anchors

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 409 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Circuits
    wrote on last edited by Circuits
    #1

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

    Row
        {
            id: idFlowDigitsEntryBox
            width: (keyWidth * 3 + keySpacing * 2) * 2
            height: 50
            anchors.bottom: idFlowDigits.top
            anchors.leftMargin: keySpacing
            spacing: keySpacing
    
            Rectangle
            {
                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"
                }
            }
    
        }
    

    error:

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

    Why am I getting this error, any ideas?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      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.

      (Z(:^

      C 1 Reply Last reply
      3
      • sierdzioS sierdzio

        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.

        C Offline
        C Offline
        Circuits
        wrote on last edited by
        #3

        @sierdzio Thanks!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved