Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How can I align Item?

How can I align Item?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 733 Views
  • 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.
  • I Offline
    I Offline
    Ibrahim
    wrote on last edited by
    #1

    Hi, my code:

      Item {
        id: header
        anchors.top: parent.top
        Row {
          anchors.fill: parent
          Image {
            id: scoreText
            anchors.verticalCenter: parent.verticalCenter
            anchors.left: header.left
            source: 'qrc:/images/score.png'
          }
          Text {
            id: score
            anchors.verticalCenter: parent.verticalCenter
            anchors.left: scoreText.right
            font.pointSize: 16
            font.bold: true
            color: '#ffffff'
            text: '11110'
          }
          Item { Layout.fillWidth:  true }
          Image {
            width: 32; height: 32
            source: 'qrc:/images/mainmenu.png'
            fillMode: Image.PreserveAspectFit
            MouseArea {
              onClicked: ;
            }
          }
        }
      }
    

    But I get this errors:
    .qml:14:7: QML Image: Cannot anchor to an item that isn't a parent or sibling.

    .qml:12:5: QML Row: Cannot specify left, right, horizontalCenter, fill or centerIn anchors for items inside Row. Row will not function.
    I want like this:
    alt text

    1 Reply Last reply
    0
    • I Offline
      I Offline
      igor_stravinsky
      wrote on last edited by
      #2

      I think that second error message is the telling one: if you're using a row to hold things in place, then you shouldn't use anchors on the left or right of objects that are in the row.

      If you need spaces around the items in the row, then you can set
      bottomPadding
      topPadding
      leftPadding
      rightPadding

      or just:

      padding

      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