PDA

View Full Version : problem with QMainWindow setCentralWidget and stackedWidget



umen
15th May 2010, 12:51
Hello
i have gui the i created in the designer , simple one .
QMainWIndow that contains stackedWidget , the application starts with
stackedWidget index 0 that contains qwebkit widget and after some user flow ,it changes to stackedWidget
index 1 that contains QTree widget , to center the first widget i use in the QMainWindow constractor this line of code
this->setCentralWidget(ui.webView); but when the application switching to index number 1 im getting exception that is
coming from the switching command .
why ?

Lykurg
15th May 2010, 13:13
You don't need to call setCentralWidget if you use your ui file correctly. Please show us some code and the content of your ui file.

umen
15th May 2010, 14:01
Hi

i need the effect im getting from the setCentralWidget that is widget that is attached to the adge of the main window ,this is the look im looking for and can't get it via the designer .
here is my set up how can i change it ?


MainWindow->resize(339, 297);

centralwidget = new QWidget(MainWindow);

centralwidget->setMaximumSize(QSize(16777214, 16777215));
verticalLayout = new QVBoxLayout(centralwidget);
verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
stackedWidget = new QStackedWidget(centralwidget);
stackedWidget->setObjectName(QString::fromUtf8("stackedWidget"));
page = new QWidget();
page->setObjectName(QString::fromUtf8("page"));
verticalLayout_2 = new QVBoxLayout(page);
verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
webView = new QWebView(page);
webView->setObjectName(QString::fromUtf8("webView"));
QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(webView->sizePolicy().hasHeightForWidth());
webView->setSizePolicy(sizePolicy);
webView->setAutoFillBackground(true);
webView->setUrl(QUrl("about:blank"));
verticalLayout_2->addWidget(webView);
stackedWidget->addWidget(page);
page_2 = new QWidget();
page_2->setObjectName(QString::fromUtf8("page_2"));
verticalLayout_3 = new QVBoxLayout(page_2);
verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
treeView = new QTreeView(page_2);
treeView->setObjectName(QString::fromUtf8("treeView"));
treeView->setAlternatingRowColors(true);
treeView->setRootIsDecorated(false);
verticalLayout_3->addWidget(treeView);
stackedWidget->addWidget(page_2);
verticalLayout->addWidget(stackedWidget);
MainWindow->setCentralWidget(centralwidget);
menubar = new QMenuBar(MainWindow);
MainWindow->setMenuBar(menubar);
statusbar = new QStatusBar(MainWindow);
statusbar->setObjectName(QString::fromUtf8("statusbar"));
MainWindow->setStatusBar(statusbar);
retranslateUi(MainWindow);
stackedWidget->setCurrentIndex(0);