29

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
  • 24,099
  • 38
  • 122
  • 179

3 Answers3

48

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

Kamil Klimek
  • 12,884
  • 2
  • 43
  • 58
  • 3
    There 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). – esac Jun 24 '10 at 14:56
  • Didn't you set size hints for fixed/maximum ? – Kamil Klimek Jun 25 '10 at 08:13
  • 3
    Ok, I've checked with Qt 4.6.2. I can't stretch it too... You can fill up a bug report to http://bugreports.qt.nokia.com/ – Kamil Klimek Jun 25 '10 at 08:15
  • 2
    **This 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](https://stackoverflow.com/users/934379/andreas-hammerschmidt)' clever [bizarro world hack](https://stackoverflow.com/a/7345212/2809027). – Cecil Curry Jun 14 '17 at 06:50
  • 2
    @KamilKlimek [**Done.**](https://bugreports.qt.io/browse/QTCREATORBUG-18392) Seven years after this issue was first unveiled, one bitter man has finally submitted an official bug to the [Qt Creator bug tracker](https://bugreports.qt.io/browse/QTCREATORBUG). 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. – Cecil Curry Jun 15 '17 at 07:20
  • Dragging the edges of a widget to change its colspan property worked for me, in Qt Designer version 4.8.4. – Mike Finch Dec 12 '17 at 15:40
11

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.

  • 1
    Qt Designer 4.8.5, 2017, still can't stretch the `QTabWidget` – CallMeLaNN Mar 29 '17 at 15:44
  • **This 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 Jun 14 '17 at 06:47
  • **Correction:** 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 Jun 14 '17 at 06:58
8

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>