Results 1 to 3 of 3

Thread: problem with QMainWindow setCentralWidget and stackedWidget

  1. #1
    Join Date
    May 2009
    Posts
    83

    Default problem with QMainWindow setCentralWidget and stackedWidget

    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 ?

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: problem with QMainWindow setCentralWidget and stackedWidget

    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.

  3. #3
    Join Date
    May 2009
    Posts
    83

    Default Re: problem with QMainWindow setCentralWidget and stackedWidget

    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 ?

    Qt Code:
    1. MainWindow->resize(339, 297);
    2.  
    3. centralwidget = new QWidget(MainWindow);
    4.  
    5. centralwidget->setMaximumSize(QSize(16777214, 16777215));
    6. verticalLayout = new QVBoxLayout(centralwidget);
    7. verticalLayout->setObjectName(QString::fromUtf8("verticalLayout"));
    8. stackedWidget = new QStackedWidget(centralwidget);
    9. stackedWidget->setObjectName(QString::fromUtf8("stackedWidget"));
    10. page = new QWidget();
    11. page->setObjectName(QString::fromUtf8("page"));
    12. verticalLayout_2 = new QVBoxLayout(page);
    13. verticalLayout_2->setObjectName(QString::fromUtf8("verticalLayout_2"));
    14. webView = new QWebView(page);
    15. webView->setObjectName(QString::fromUtf8("webView"));
    16. QSizePolicy sizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    17. sizePolicy.setHorizontalStretch(0);
    18. sizePolicy.setVerticalStretch(0);
    19. sizePolicy.setHeightForWidth(webView->sizePolicy().hasHeightForWidth());
    20. webView->setSizePolicy(sizePolicy);
    21. webView->setAutoFillBackground(true);
    22. webView->setUrl(QUrl("about:blank"));
    23. verticalLayout_2->addWidget(webView);
    24. stackedWidget->addWidget(page);
    25. page_2 = new QWidget();
    26. page_2->setObjectName(QString::fromUtf8("page_2"));
    27. verticalLayout_3 = new QVBoxLayout(page_2);
    28. verticalLayout_3->setObjectName(QString::fromUtf8("verticalLayout_3"));
    29. treeView = new QTreeView(page_2);
    30. treeView->setObjectName(QString::fromUtf8("treeView"));
    31. treeView->setAlternatingRowColors(true);
    32. treeView->setRootIsDecorated(false);
    33. verticalLayout_3->addWidget(treeView);
    34. stackedWidget->addWidget(page_2);
    35. verticalLayout->addWidget(stackedWidget);
    36. MainWindow->setCentralWidget(centralwidget);
    37. menubar = new QMenuBar(MainWindow);
    38. MainWindow->setMenuBar(menubar);
    39. statusbar = new QStatusBar(MainWindow);
    40. statusbar->setObjectName(QString::fromUtf8("statusbar"));
    41. MainWindow->setStatusBar(statusbar);
    42. retranslateUi(MainWindow);
    43. stackedWidget->setCurrentIndex(0);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 2
    Last Post: 17th May 2009, 21:58
  2. Problem with setCentralWidget
    By blm in forum Qt Programming
    Replies: 3
    Last Post: 2nd September 2008, 12:33
  3. Replies: 2
    Last Post: 7th June 2008, 13:12
  4. QMainWindow setCentralWidget from ui widget, Qt4
    By alan in forum Qt Programming
    Replies: 5
    Last Post: 13th May 2008, 13:00
  5. Replies: 4
    Last Post: 7th March 2007, 09:45

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.