Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Designer - How to get a widget to span columns?

I created a simple form. I added a PushButton in the bottom right, and then a TabWidget above that. I highlighted the main window, and chose Grid Layout. The PushButton was stretched, so I added a spacer to the left of it.

Now, my Tab Widget only occupies the left most column. I want it to span into Column1 as well. I looked through every option and tried right-clicking anywhere, and can not get the designer to create the span.

Just to make sure I wasn't missing anything, I modified the .ui file directly, added colspan="2" to the tag for the Tab Widget, reloaded it with designer, and it is displaying perfectly. However, I want to use the designer as much as possible.

Any ideas how to get this to span?

like image 875
esac Avatar asked Jun 23 '10 22:06

esac


People also ask

How are widgets added to a grid layout?

The normal way to add a layout is by calling addLayout() on the parent layout. Once you have added your layout you can start putting widgets and other layouts into the cells of your grid layout using addWidget(), addItem(), and addLayout().

How do I resize a layout in Qt?

Once you have add your layout with at least one widget in it, select your window and click the "Update" button of QtDesigner. The interface will be resized at the most optimized size and your layout will fit the whole window. Then when resizing the window, the layout will be resized in the same way.


2 Answers

Well... It's simple "drag operation". Just grab edge of your TabWidget closest to column you want span. And now just simply "stretch" TabWidget on empty column... It should now "span" on both columns

like image 126
Kamil Klimek Avatar answered Sep 28 '22 08:09

Kamil Klimek


If you have problems stretching the TabWidget (there is a bug in at least 4.6.2-4.7.3) you can right click it, convert it to a QToolBox, stretch it, right click it again and convert it back to a QTabWidget.

I tried this with an empty QTabWidget and do not know what happens if you already added some child widgets to it.

like image 36
Andreas Hammerschmidt Avatar answered Sep 28 '22 08:09

Andreas Hammerschmidt