Qt Designed and Grid Layout: how to span multiple columns/rows?
-
wrote on 17 Jan 2011, 09:10 last edited by
Is it possible, with the designed, configure a widget to span over multiple columns/rows, as I can do width addWidget()?
-
wrote on 17 Jan 2011, 09:30 last edited by
I just tried it: yes, it is.
@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>193</width>
<height>85</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<widget class="QWidget" name="">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>158</width>
<height>54</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pushButton_2">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<resources/>
<connections/>
</ui>
@ -
wrote on 17 Jan 2011, 09:51 last edited by
[quote author="Andre" date="1295256652"]I just tried it: yes, it is.
@
<layout class="QGridLayout" name="gridLayout">
...
<item row="1" column="0" colspan="2">
...
@[/quote]Do You mean I have to manually change the ui file? I cannot find I "visual" way to do it inside the Qt Designer (running from Qt Creator on Windows XP, Qt 4.7.0).
-
wrote on 17 Jan 2011, 09:55 last edited by
No, I created the file completely with designer itself.
What I did was drop the three buttons in roughly the way I wanted them (so with the bottom botton spanning the width of both top buttons together), selected them, and applied a grid layout on them. I pasted the resulting .ui file.
Edit:
You can also change it later. I just dropped an additional button on the grid on the right, and Qt Designer created another column and put the button in the new top-right cell. Now I just dragged the button's bottom edge downwards, over the border of the cell, and Designer made the top right cell span two rows and put the button in the middle of it.Feels quite natural to me.
-
wrote on 17 Jan 2011, 10:03 last edited by
! Its was too simple to find! I'm sorry. It can also be done on an existing layout by simple dragging a side of a widget over the adjacent cell.
Thanks
-
wrote on 17 Jan 2011, 11:00 last edited by
That's a nice feature. I am not going mad anymore with layouts :-)
[quote author="calberto" date="1295258628"]! Its was too simple to find! I'm sorry. It can also be done on an existing layout by simple dragging a side of a widget over the adjacent cell.Thanks
[/quote] -
wrote on 7 Feb 2015, 18:26 last edited by
The answer that keeps on giving. Thanks that was driving me nuts trying to get a button box to span across the bottom of a 3 column grid layout.
-
wrote on 7 Feb 2015, 18:26 last edited by
The answer that keeps on giving. Thanks that was driving me nuts trying to get a button box to span across the bottom of a 3 column grid layout.