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. RowLayout: align one item at right
Forum Updated to NodeBB v4.3 + New Features

RowLayout: align one item at right

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 3 Posters 1.9k 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.
  • T Offline
    T Offline
    Tobias Fensch
    wrote on last edited by
    #1

    Hello,

    why is this not aligning the red rectangle at the right side of the parent:

    RowLayout {
        Layout.fillWidth: true
        Layout.preferredHeight: 32
    
        Label {
            Layout.preferredHeight: 28
            verticalAlignment: Text.AlignVCenter
            text: qsTr("Skript-Datei:")
        }
        TextField {
            Layout.preferredWidth: 400
            Layout.preferredHeight: 28
            readOnly: true
            text: settings.scriptFilePath
        }
        Button {
            Layout.preferredWidth: 32
            Layout.preferredHeight: 28
            text: "..."
            onClicked: fileDialog.open()
            enabled: !scriptingViewModel.isRunning
        }
        Rectangle {
            Layout.preferredWidth: 60
            Layout.preferredHeight: 28
            Layout.alignment: Qt.AlignRight
            Layout.rightMargin: 40
    
            color: "red"
        }
    }
    

    5ac0803b-14d8-4ba9-a98b-2636780d5942-grafik.png
    regards,
    Tobias

    1 Reply Last reply
    0
    • M Offline
      M Offline
      matzze54
      wrote on last edited by
      #3

      You can try to put some kind of spacing item in between the Button and the Rectangle which fills the remaining width, instead of using Layout.alignment.

      [...]
      
          Button {
              Layout.preferredWidth: 32
              Layout.preferredHeight: 28
              text: "..."
              onClicked: fileDialog.open()
              enabled: !scriptingViewModel.isRunning
          }
      
          Item {
              // spacer
              Layout.fillHeight: true
              Layout.fillWidth: true
          }
      
          Rectangle {
              Layout.preferredWidth: 60
              Layout.preferredHeight: 28
              //Layout.alignment: Qt.AlignRight
              Layout.rightMargin: 40
      
              color: "red"
          }
      

      I do normally use an opposite Layout for such purposes, as they fill height and width by default.

      1 Reply Last reply
      1
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by
        #2

        What's the parent of your RowLayout?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          matzze54
          wrote on last edited by
          #3

          You can try to put some kind of spacing item in between the Button and the Rectangle which fills the remaining width, instead of using Layout.alignment.

          [...]
          
              Button {
                  Layout.preferredWidth: 32
                  Layout.preferredHeight: 28
                  text: "..."
                  onClicked: fileDialog.open()
                  enabled: !scriptingViewModel.isRunning
              }
          
              Item {
                  // spacer
                  Layout.fillHeight: true
                  Layout.fillWidth: true
              }
          
              Rectangle {
                  Layout.preferredWidth: 60
                  Layout.preferredHeight: 28
                  //Layout.alignment: Qt.AlignRight
                  Layout.rightMargin: 40
          
                  color: "red"
              }
          

          I do normally use an opposite Layout for such purposes, as they fill height and width by default.

          1 Reply Last reply
          1

          • Login

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