Results 1 to 3 of 3

Thread: UI implementation style

  1. #1
    Join Date
    Jul 2007
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default UI implementation style

    Requesting advice for QStackedWidget, QMainWindow program I am trying to get going.

    I have a Qt Designer UI which contains a QStackedWidget in a QMainWindow, with a toolbar above the stackedWidget (fairly straightforward). I would like to create separate classes which represent each page of the stackedWidget (for manageability).

    Since Designer has one file for the whole GUI how would I put the whole thing together? I was thinking something like the following:
    mainWindow.h & .cpp (construct the gui and implement toolbar buttons to change pages on the qstackedwidget)
    page1.h & .cpp (exclusively control page 1)
    page2 ..... and so on.

    First, does this sound like a good plan?
    Second, pretty sure I would #include the ui_UIfilename.h in all the classes THEN what? - (my guess would be to itemize the objects again in their respective places in the header file a.k.a. public:, private: public slots: etc).
    If there is a tutorial or example or another forum question, please don't hesitate to point me there - or any personal preferences on the implementation of Designer based gui's
    Goes2BoB

  2. #2
    Join Date
    Mar 2007
    Posts
    74
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: UI implementation style

    I did almost the same thing...

    1. In Qt Designer, name your form objectname something ie. myStackedPage1

    2. In your build (I use VC++) add the .ui for the form file.
    The build will generate an ui_myStackedPage1.h include file.

    3. Create .cpp and .h files that are based on this UI file, similar
    to how mainwindow does it for it's ui file.

    ie.

    class Page1Property : public QWidget, private Ui::myStackedPage1

    Page1Property::Page1Property(QWidget *parent)
    : QWidget(parent)
    {
    setupUi(this);
    }

    You now have access from within this class to setupUi() for this ui file.

    In main you then scroll through the stacked widgets add a layout for each and
    place you form on the appropriate page.

    int pages = WorkspacestackedWidget->count();
    QWidget *thisWidget;
    QLabel *m_emptyPage;
    for (int i = 1; i < pages; ++i)
    {
    // Install a layout manager for all of the stacked pages
    StackedFormLayout = new QGridLayout;
    thisWidget = WorkspacestackedWidget->widget(i);
    thisWidget->setLayout(StackedFormLayout);
    thisWidget->layout()->setMargin(0);

    myStackedPage1= new myStackedPage1
    thisWidget->layout()->addWidget(myStackedPage1);
    }



    Mark

  3. #3
    Join Date
    Jul 2007
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: UI implementation style

    Thanks for the help. Should I say that I am pretty new to C++? Can you offer any more help - i.e. what would the myStackedPage1.h look like (abridged version) and what would myStackedPage1.cpp look like (also abridged version)? would appreciate it.

Similar Threads

  1. Qt 4.3 Style sheet, new features
    By Angelo Moriconi in forum Qt Programming
    Replies: 2
    Last Post: 12th June 2007, 15:22
  2. Set appropriate style for the user's platform ?
    By whitefurrows in forum Qt Programming
    Replies: 9
    Last Post: 22nd May 2007, 00:57
  3. Setting a Style Issue
    By forrestfsu in forum Qt Programming
    Replies: 5
    Last Post: 28th March 2007, 21:32
  4. about scrollbar style
    By qtopiahooo in forum Qt Programming
    Replies: 1
    Last Post: 25th January 2007, 13:34
  5. Custom Style
    By Dusdan in forum Qt Tools
    Replies: 8
    Last Post: 1st September 2006, 22:50

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.