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 could I force ComboBox fill the width when I wrap it in GroupBox(QtQuick control 2)?
QtWS25 Last Chance

How could I force ComboBox fill the width when I wrap it in GroupBox(QtQuick control 2)?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 1.5k 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.
  • thamT Offline
    thamT Offline
    tham
    wrote on last edited by
    #1

    Before I wrap the ComboBox inside the Groupbox, width of the ComboBox can fill the width, but after I wrap it by GroupBox, the Layout.fillWidth do not work anymore, how could I fix that?Thanks

    import QtQuick 2.9
    import QtQuick.Controls 2.2
    import QtQuick.Layouts 1.3
    
    Rectangle {
        id: root
    
        width: 480
        height: 480
    
        ColumnLayout{
            anchors.fill: parent
            spacing: 5
    
            GroupBox{            
                title: qsTr("Face database select")
                Layout.fillWidth: true
                GridLayout{
                    columns: 2
                    Layout.fillWidth: true
    
                    Label{
                        text: qsTr("Select DB")
                    }
                    ComboBox{
                        Layout.fillWidth: true
                    }
    
                }
            }
    
            Item{
                Layout.fillHeight: true
                Layout.fillWidth: true
            }
        }
    
    }
    

    Result after wrap in the GroupBox

    Result

    J 1 Reply Last reply
    0
    • thamT tham

      Before I wrap the ComboBox inside the Groupbox, width of the ComboBox can fill the width, but after I wrap it by GroupBox, the Layout.fillWidth do not work anymore, how could I fix that?Thanks

      import QtQuick 2.9
      import QtQuick.Controls 2.2
      import QtQuick.Layouts 1.3
      
      Rectangle {
          id: root
      
          width: 480
          height: 480
      
          ColumnLayout{
              anchors.fill: parent
              spacing: 5
      
              GroupBox{            
                  title: qsTr("Face database select")
                  Layout.fillWidth: true
                  GridLayout{
                      columns: 2
                      Layout.fillWidth: true
      
                      Label{
                          text: qsTr("Select DB")
                      }
                      ComboBox{
                          Layout.fillWidth: true
                      }
      
                  }
              }
      
              Item{
                  Layout.fillHeight: true
                  Layout.fillWidth: true
              }
          }
      
      }
      

      Result after wrap in the GroupBox

      Result

      J Offline
      J Offline
      jpnurmi 0
      wrote on last edited by
      #2

      Layout.fillWith: true has only effect on Items that are in a Layout. Your GridLayout is not in a Layout, but in a GroupBox.

      GroupBox {
          GridLayout {
              anchors.fill: parent
          }
      }
      
      thamT 1 Reply Last reply
      3
      • J jpnurmi 0

        Layout.fillWith: true has only effect on Items that are in a Layout. Your GridLayout is not in a Layout, but in a GroupBox.

        GroupBox {
            GridLayout {
                anchors.fill: parent
            }
        }
        
        thamT Offline
        thamT Offline
        tham
        wrote on last edited by tham
        #3

        @jpnurmi-0 Is it possible to make Layout.fillWidth work if I wrap the GridLayout in the GroupBox, I tried to wrap GridLayout by RowLayout, but it do not work either.

        import QtQuick 2.9
        import QtQuick.Controls 2.2
        import QtQuick.Layouts 1.3
        
        Rectangle {
            id: root
        
            width: 480
            height: 480
        
            ColumnLayout{
                anchors.fill: parent
                spacing: 5
        
                GroupBox{
                    title: qsTr("Face database select")
                    Layout.fillWidth: true
        
                    RowLayout{
                        Layout.fillWidth: true //with or without this line has no effect
                        GridLayout{
                            columns: 2
                            Layout.fillWidth: true
        
                            Label{
                                text: qsTr("Select DB")
                            }
                            ComboBox{
                                Layout.fillWidth: true
                            }
        
                        }
                    }
                }
        
                Item{
                    Layout.fillHeight: true
                    Layout.fillWidth: true
                }
            }
        
        }
        
        

        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