Results 1 to 4 of 4

Thread: QStackedWidget and QTabWidget Structure Advice

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Aug 2009
    Location
    Belgium
    Posts
    310
    Thanks
    10
    Thanked 31 Times in 25 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QStackedWidget and QTabWidget Structure Advice

    Hi,

    For each QStackedWidget page you need, create a dialog instead that contains the tabwidget with approximately 5 tabs.
    Create your main dialog or mainwindow, and put a QStackedWidget on it.
    Instantiate each of you dialogs, and add them to the QStackedWidget.

    This way you can easily create your different screens visually in Designer without creating a class with a giant number of widgets in it.

    Code snippets from a project of mine :

    Qt Code:
    1. frmRealParts = new CRealPartsForm(this); // add form with Real parts
    2. ui->twComponents->addTab( frmRealParts, "Realparts" );
    3. frmDistParts = new CDistPartsForm(this); // add form with Distributer parts
    4. ui->twComponents->addTab( frmDistParts, "Distributer" );
    To copy to clipboard, switch view to plain text mode 

    I use a tabwidget (ui->twComponents) to put other dialogs in (CRealPartsForm and CDistPartsForm, which are just dialogs). QStackedWidget has a similar method addWidget() afaik. This code is put in the constructor of my main form, after the ui->setupUI(this);

    Best regards,
    Marc

  2. The following 2 users say thank you to marcvanriet for this useful post:

    certqt (16th November 2010), crsn (22nd March 2011)

Similar Threads

  1. problem with QStackedwidget
    By psantofe in forum Qt Programming
    Replies: 3
    Last Post: 14th April 2010, 12:41
  2. Help with QStackedWidget
    By onírico in forum Newbie
    Replies: 6
    Last Post: 12th November 2009, 16:34
  3. Some advice on how to structure this program?
    By mrwooster in forum Newbie
    Replies: 13
    Last Post: 12th August 2009, 14:24
  4. Forms or QStackedWidget
    By hgedek in forum Newbie
    Replies: 1
    Last Post: 5th November 2007, 21:35
  5. QStackedLayout vs. QStackedWidget
    By bruccutler in forum Qt Programming
    Replies: 1
    Last Post: 12th March 2007, 23:43

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
  •  
Qt is a trademark of The Qt Company.