PDA

View Full Version : Qt Designer QTabWidget: How to add a layout to a tab?



flipflop
12th May 2011, 06:39
Hello everybody,

there exist any way to add a layout to a tab? something like as shown in this link:

http://doc.trolltech.com/4.4/designer-using-containers.html

I think that in qt4.5 this feature was broken (in qt-designer), but maybe I'm wrong.

The only way in which I can add a layout to a tab is create a tab (in qt-designer) and then edit manually this tab by adding

<layout class="QGridLayout" name="gridLayout">
</layout>

but this sucks,

regards,
flipflop

wysota
12th May 2011, 06:46
What is/was broken? QTabWidget is in no way different than other widgets. Everything works as expected.

flipflop
12th May 2011, 20:02
What is/was broken? QTabWidget is in no way different than other widgets. Everything works as expected.

Hi wysota, thanks for your response, could you see this video explanation? :

http://www.youtube.com/watch?v=8JYEdXDhrTY

in this video you can see the problem and a way to avoid it, but the problem still remains, the problem is that you can't add a layout to a tab without any widget, if you add a widget (a QGridLayout for example, like in this video) then everything works fine,

regards,
flipflop

wysota
13th May 2011, 09:22
Again, QTabWidget is by no means different than any other widget. If you create a plain QWidget, layouting options will also be disabled because there is nothing to manage by the layout. That's a logical and expected behaviour.

Zaph
12th October 2012, 11:21
I came here wondering about the same thing.

I think what wysota is trying to say, but can't help but be a dïck about it, is that you need to add one or more widgets into the QTabWidget (or QGroupBox) before you can set the layout by right-clicking and opening the context menu.

Not really one of the most intuitive features of the form designer.

vmlich
13th March 2013, 11:26
In designer You should first in form preview select requested tab, than in tree-view click to PARENT QTabWidget and set the layout as for all tabs. Really this layout appears as new properties for selected tab only. Every tab has own layout.

astodolski
16th May 2013, 21:56
I came here wondering about the same thing.

I think what wysota is trying to say, but can't help but be a dïck about it

Is that necessary?

Mohammad_Aqajani
29th June 2017, 14:49
setCurrentIndex method of QTabWidget class takes a QWidget object as an argument so:
all you have to do is create a new QWidget object and use the setLayout method to set your layout to that object:
yourLayout = QVBoxLayout() #or whatever else
w = QWidget()
w.setLayout( yourLayout )
addTab(w)