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 to make only one column in a GridLayout expand on resize ?
Forum Updated to NodeBB v4.3 + New Features

How to make only one column in a GridLayout expand on resize ?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 187 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.
  • F Offline
    F Offline
    foobarbaz
    wrote on last edited by
    #1

    Dear Community,

    I know there are plenty of questions regarding the Layout management, but I didn't find anything that would fit my needs :)
    I want to achieve the following behaviour (left pic on creation, right pic on resize):

    6bb7f30f-1b16-4532-89d5-31bb76baa546-изображение.png

    Note that

    1. That bright red rectangle must expand, other ones - must not.
    2. Columns are not necessarily of equal width, it doesn't matter. But they should be aligned (as in the pic)

    I tried several ways with no success. So here is a simple snippet to demonstrate my wish:

    GridLayout {
        id: grid
    
        columns: 4
    
        // Row 0
        Label {
            text: "foo"
        }
    
        Label {
            text:               "bar bar bar"
            Layout.columnSpan:  2
            Layout.fillWidth:   true
        }
    
        // The one who is supposed to take extra space on resizing
        Item {
            Layout.fillWidth: true
        }
    
        // Row 3
        Rectangle {
            implicitHeight:     10
            Layout.columnSpan:  4
            Layout.fillWidth:   true
            color:              "red"
        }
    
        // Row 2
        Label {
            text: "baz"
        }
    
        Button {
            text:               "qux"
            Layout.fillWidth:   true
        }
    
        Button {
            text:               "waldo"
            Layout.fillWidth:   true
        }
    
        // The one who is supposed to take extra space on resizing
        Item {
            Layout.fillWidth: true
        }
    
        // ... etc.
    }
    

    Thank you in advance !

    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