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. Sizing items in Qt Quick 2.0
QtWS25 Last Chance

Sizing items in Qt Quick 2.0

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 958 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.
  • R Offline
    R Offline
    rizoritis
    wrote on last edited by
    #1

    Hello,

    I am trying to give a fixed size to PushButton and GroupBox while coding QML. I am finding that no matter what I put for "height: xx" or "width: xx", the item does not change size. Below is one example for the PushButton:

    @ Button {
    id: connectButton

            width: 100
    
            anchors.right: spacer2.left
            anchors.verticalCenter: parent.verticalCenter
    
            text: qsTr("Connect")
        }@
    

    Could anyone explain why I cannot define a fixed size for anything.

    Thanks

    1 Reply Last reply
    0
    • frederikF Offline
      frederikF Offline
      frederik
      wrote on last edited by
      #2

      Where does you Button come from? Without seeing it's implementation it is impossible to answer this question.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rizoritis
        wrote on last edited by
        #3

        [quote author="frederik" date="1389892420"]Where does you Button come from? Without seeing it's implementation it is impossible to answer this question.[/quote]

        The following is the complete code:

        @Rectangle {
        id: root

        width: 750
        height: 360
        
        SplitView {
            anchors.fill: parent
        
            ToolBar {
                id: mainToolBar
        
                width: 60
        
                anchors.top: parent.top
                anchors.bottom: parent.bottom
        
                ColumnLayout {
                    //height: parent.height
                    //anchors.bottomMargin: 20
        
                    ToolButton {
                        id: homeToolButton
                        text: qsTr("HOME")
                        onClicked: root.color = "white"
                    }
        
                    ToolButton {
                        id: jogToolButton
                        text: qsTr("JOG")
                        onClicked: root.color = "green"
                    }
        
                    ToolButton {
                        id: defsToolButton
                        text: qsTr("DEFS")
                        onClicked: root.color = "blue"
                    }
        
                    ToolButton {
                        id: payloadToolButton
                        text: qsTr("PAYLOAD")
                        onClicked: root.color = "red"
                    }
        
                    ToolButton {
                        id: limitsToolButton
                        text: qsTr("LIMITS")
                        onClicked: root.color = "yellow"
                    }
        
                    ToolButton {
                        id: programToolButton
                        text: qsTr("PROGRAM")
                        onClicked: root.color = "orange"
                    }
        
                    ToolButton {
                        id: ioToolButton
                        text: qsTr("I/O")
                        onClicked: root.color = "brown"
                    }
        
                    ToolButton {
                        text: qsTr("SETTINGS")
                        onClicked: root.color = "black"
                    }
        
                    ToolButton {
                        id: modeToolButton
                        text: qsTr("MODE")
                        onClicked: root.color = "purple"
                    }
                }
            }
        
            RowLayout {
                id: rowLayout1
        
                height: 30
        
                anchors.top: parent.top
                anchors.right: parent.right
                anchors.margins: 10
        
                Text {
                    id: gantryText
        
                    width: 30
        
                    text: qsTr("Gantry:")
        
                    anchors.left: parent.left
                    anchors.verticalCenter: parent.verticalCenter
                }
        
                ComboBox {
                    id: gantryComboBox
        
                    model: 5
        
                    anchors.left: gantryText.right
                    anchors.right: spacer1.left
                    anchors.leftMargin: 10
                    anchors.verticalCenter: parent.verticalCenter
                }
        
                Text {
                    id: spacer1
        
                    width: 400
        
                    anchors.right: connectButton.left
                    anchors.verticalCenter: parent.verticalCenter
                }
        
                Button {
                    id: connectButton
        
                    width: 100
        
                    anchors.right: spacer2.left
                    anchors.verticalCenter: parent.verticalCenter
        
                    text: qsTr("Connect")
                }
        
                Text {
                    id: spacer2
        
                    width: 20
        
                    anchors.right: disconnectButton.left
                    anchors.verticalCenter: parent.verticalCenter
                }
        
                Button {
                    id: disconnectButton
        
                    width: 100
        
                    anchors.right: parent.right
                    anchors.verticalCenter: parent.verticalCenter
        
                    text: qsTr("Disconnect")
                }
            }
        
            RowLayout {
                anchors.top: rowLayout1.bottom
                anchors.right: parent.right
                anchors.bottom: parent.bottom
                anchors.margins: 10
        
                ColumnLayout {
                    anchors.top: parent.top
                    anchors.bottom: parent.bottom
                    anchors.left: parent.left
                    anchors.right: homePosGroupBox.left
                    anchors.margins: 10
        
                    GroupBox {
                        id: powerGroupBox
        
                        anchors.top: parent.top
                        anchors.bottom: homeGroupBox.top
                        anchors.left: parent.left
                        anchors.right: parent.right
        
                        title: qsTr("Motors")
                    }
        
                    GroupBox {
                        id: homeGroupBox
        
                        anchors.bottom: parent.bottom
                        anchors.left: parent.left
                        anchors.right: parent.right
                        anchors.topMargin: 10
        
                        title: qsTr("Home")
                    }
                }
        
                GroupBox {
                    id: homePosGroupBox
        
                    width: 350
        
                    anchors.top: parent.top
                    anchors.bottom: parent.bottom
                    anchors.right: parent.right
                    anchors.margins: 10
        
                    title: qsTr("Home Position")
                }
            }
        }
        

        }@

        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