Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, May 2007
how to resize the geometry of widget return from another class?


Message 1 in thread

hi,all
i create a class appCentralWidget to setup app's centralwidget
and call appCentralWidget::getCW() to return this centralwidget
in class appMainWindow,i use createCentralWidget to setup centralwidget:
void appMainWindow::createCentralWidget()
{
        appCentralWidget *mainCW=new appCentralWidget();
        QTabWidget *tabwidget=new QTabWidget(this);
        tabwidget->addTab(mainCW->getCW(),"app1");
        setCentralWidget(tabwidget);
        tabwidget->show();
}
it works but not well,when i resize the geometry of mainwindow
,tabwidget resizes too,but the widget
return from mainCW->getCW() doesnt resize,its geometry seems fixed

i tried to add extra layout:
void appMainWindow::createCentralWidget()
{
        appCentralWidget *mainCW=new appCentralWidget();
        QTabWidget *tabwidget=new QTabWidget(this);

        QWidget *mw=new QWidget(tabwidget);
        QHBoxLayout *ml=new QHBoxLayout(mw);
        ml->addWidget(mainCW->getCW());
        tabwidget->addTab(mw,"aaaaaaaa");
        setCentralWidget(tabwidget);
        tabwidget->show();
}
it comes with
QLayout: Adding QWidget/unnamed (top-level widget) to layout for QWidget/unnamed

and mainCW()->getCW() invisibal

any suggestion is appropriated

regards
jiang jefix

--
 [ signature omitted ]