QTabWidget: How to add a layout to a tab?
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/designe...ontainers.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
1 Attachment(s)
Re: QTabWidget: How to add a layout to a tab?
What is/was broken? QTabWidget is in no way different than other widgets. Everything works as expected.
Re: QTabWidget: How to add a layout to a tab?
Quote:
Originally Posted by
wysota
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
Re: QTabWidget: How to add a layout to a tab?
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.
Re: QTabWidget: How to add a layout to a tab?
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.
Re: QTabWidget: How to add a layout to a tab?
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.
Re: QTabWidget: How to add a layout to a tab?
Quote:
Originally Posted by
Zaph
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?
Re: QTabWidget: How to add a layout to a tab?
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)