Important: Please read the Qt Code of Conduct -

Grid layout spacing issue (Solved)

  • Hi,

    I have cerated two grid layout inside a Rowlayout. It is working fine as i can see that each gridlayout with buttons.

    But i have a problem that one gridlayout conists of 5 buttons and another one with 4 buttons. When i see the output the alignment looks in different size for each grids. If i provide same buttons for two grids then it will show the same alignment. But is there any way i can manage this without adding another button to make both equal.


  • Hello,

    you can set the Layout.minimumWidth: on the thiner or both Layouts. Just set them both to half of the window and they will use a minimum of half of the window:
    @Rectangle {
    width: 300; height: 300
    RowLayout {
    GridLayout {
    Layout.minimumWidth: 150
    GridLayout {
    Layout.minimumWidth: 150

    For further information please read:

  • Hello, You can also span one button for more than one row using Layout.rowSpan

  • Or use an invisible Rectangle to fill a row. :)

  • [quote author="onek24" date="1395397082"]Or use an invisible Rectangle to fill a row. :)[/quote]


    Thanks gain and sorry for the late reply.
    I have tried rowspan and its working fine. Anyway the last options is nice, as we can set opacity of a button to -1 and it will create an empty space there.
    Any way my problem is solved, thanks again.


  • Hey,

    i'm glad that it is solved. You can also set the color of the rectangle to "transparent", that will work too. Anyways, please add [solved] to the topic, thank you.


Log in to reply