[Qt-interest] How to Make a TabWidget a `CentralWidget' ?

Aaron Lewis aaron.lewis1989 at gmail.com
Tue Apr 6 13:52:37 CEST 2010


Thanks Diego,i should've be more specific.

Before i want to try with TabWidget , i use a `mainLayout' as layout
(QHBox , QVBOX , etc.) ,  and morph it into a QWidget.

In construct function:

mainw::mainw(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::pangolin)
{
    ui->setupUi(this);
    setCentralWidget(ui->tabWidget);
}

That's all my Code , not working this time.

On 04/06/2010 07:28 PM, Diego Iastrubni wrote:
> You are missing the point.
> 
> Lets assume the UI is a QWidget, and contains a QTabWidget:
> QWidget *babla(this);
> ui.setupUi(blabla);
> setCentralWidget(blabla);
> ui.tabWidget->...
> 
> 
> Lets assume the UI is a QMainWindow and contains a QTabWidget:
> ui.setupUi(this);
> ui.tabWidget->...
> 
> You don't need to make the tab widget the central widget. At least not
> directly... A third option might be:
> 
> class fooWindow: public QMainWindow{
>   QTabWidget *tb;
>   fooWindow(QWidget *parent): QMainWindow(parent)
>   {
>     tb = new QTabWidget(this);
>     setCentralWidget(tb);
>   }
> };
> 
> Either you use the designer - or not. Decide how do you want to work.
> 
> 
> On Tue, Apr 6, 2010 at 11:38 AM, Aaron Lewis <aaron.lewis1989 at gmail.com>wrote:
> 
>> Hi,
>>        I've got a MainWindow , which has a QTabWidget inside. ( 2 tabs )
>>
>>        What i want is to make this TabWidget Central.
>>
>>        Normally i will use setCentralWidget(ui->tabWidget) in contruct
>> function , but this ain't going to work this time.
>>
>>        Does anyone has any ideas ?
>>
>>        Thanks in advance !
>>
>>
>> --
>> Best Regards,
>> Aaron Lewis - PGP: 0x4A6D32A0
>> FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
>> irc: A4r0n on freenode
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
> 


-- 
Best Regards,
Aaron Lewis - PGP: 0x4A6D32A0
FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
irc: A4r0n on freenode



More information about the Qt-interest-old mailing list