Qt Designer - How to get a widget to span columns?
Solution 1
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
Solution 2
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.
Solution 3
I find it useful to edit *.ui file by hand in some cases! according to XML Schema provided here http://harmattan-dev.nokia.com/docs/library/html/qt4/designer-ui-file-format.html you can span multiple columns by editing tag, and adding "colspan" and "rowspan" attributes, forexample:
< item row="0" column="0" colspan="3"> ... < /item>
Related videos on Youtube
esac
I am a software developer primarily focused on WinForms development in C#. I have been in development for 10 years.
Updated on March 19, 2020Comments
-
esac over 4 years
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?
-
esac about 14 yearsThere must be a bug on Tab Widget. it works for List Widget. Although Tab Widget displays the handle bar, when you drag it, it does nothing (it doesnt stretch).
-
Kamil Klimek about 14 yearsDidn't you set size hints for fixed/maximum ?
-
Kamil Klimek about 14 yearsOk, I've checked with Qt 4.6.2. I can't stretch it too... You can fill up a bug report to bugreports.qt.nokia.com
-
CallMeLaNN about 7 yearsQt Designer 4.8.5, 2017, still can't stretch the
QTabWidget
-
Cecil Curry about 7 yearsThis is insanity. This sage advice actually works, but cost me precious sanity. For the uninitiated, note that "convert it to a QToolBox" means select
Morph into -> QToolBox
from the right-clicked context menu of the QTabWidget. Note also that, as a QTabWidget and QToolBox are perfectly interchangeable, this is perfectly safe. Converting between a non-empty QTabWidget and QToolBox is a lossless operation. The contents of the QTabWidget will be preserved as is without loss. -
Cecil Curry about 7 yearsThis doesn't actually work, due to a nearly decade-old issue in Qt (Creator|Designer). Why is this the accepted answer? Surely this never worked as advertised. For a working solution, see Andreas' clever bizarro world hack.
-
Cecil Curry about 7 yearsCorrection: converting between a non-empty QTabWidget and QToolBox is slightly lossy, sadly: doing so resets the titles of all existing tabs to the empty string. While ultimately a small price to pay, you probably won't want to pay it more than once.
-
Cecil Curry about 7 years@KamilKlimek Done. Seven years after this issue was first unveiled, one bitter man has finally submitted an official bug to the Qt Creator bug tracker. This is ridiculous, people. In the future, please submit non-ignorable bug reports to the responsible parties rather than embedding ignorable complaints in StackOverflow comments. There is a world outside of StackOverflow. It deserves our full attention.
-
Mike Finch over 6 yearsDragging the edges of a widget to change its colspan property worked for me, in Qt Designer version 4.8.4.