Results 1 to 8 of 8

Thread: Can you create a custom multi-page QWizard with QtDesigner

  1. #1
    Join Date
    Mar 2009
    Location
    Tennessee, US
    Posts
    41
    Thanks
    3
    Thanked 11 Times in 8 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Unhappy Can you create a custom multi-page QWizard with QtDesigner

    I have been using the QtDesigner to make a wizard. I have started with a QWizard object and made my 8 page designs and everything was going smooth. As I started to customize the QWizard class and seed the drop-down lists and table widgets on all the pages, I notice that there doesn’t seem to be any way to use the registerField() functions for all the wizard pages. I would have expected this to be automatically by the QWizardPage, but it isn't. Even after promoting the QWizardPage objects to a custom class, I don’t have access to the wizard’s ui which holds all of the pages.

    Am I doing something wrong, missing something, or it just hard to use the QtDesigner to make wizards?

    Any help would be appreciated.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,620
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Can you create a custom multi-page QWizard with QtDesigner

    I have a QWizard and set of QWizardPages built with Designer. The pages have been promoted but that is not particularly relevant. In my page constructors:
    Qt Code:
    1. #include <QFileDialog>
    2.  
    3. #include "importfilepage.h"
    4. #include "ui_importfilepage.h"
    5.  
    6. ImportFilePage::ImportFilePage(QWidget *parent) :
    7. QWizardPage(parent),
    8. m_ui(new Ui::ImportFilePage)
    9. {
    10. m_ui->setupUi(this);
    11.  
    12. // Cannot be set in Designer?
    13. setPixmap(QWizard::LogoPixmap, QPixmap(":/wizard/logo1.png"));
    14.  
    15. // Fields
    16. registerField("fileName*", m_ui->fileNameEdit);
    17. }
    18. ...
    To copy to clipboard, switch view to plain text mode 
    Does that help?

    AFAICT there are some convenience things missing from the Designer, like setting pixmaps, but this doesn't stop you finishing the UI in code.

  3. #3
    Join Date
    Oct 2012
    Location
    The land of pain (NY)
    Posts
    99
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default Re: Can you create a custom multi-page QWizard with QtDesigner

    Quote Originally Posted by ChrisW67 View Post
    I have a QWizard and set of QWizardPages built with Designer. The pages have been promoted but that is not particularly relevant. In my page constructors:
    Qt Code:
    1. #include <QFileDialog>
    2.  
    3. #include "importfilepage.h"
    4. #include "ui_importfilepage.h"
    5.  
    6. ImportFilePage::ImportFilePage(QWidget *parent) :
    7. QWizardPage(parent),
    8. m_ui(new Ui::ImportFilePage)
    9. {
    10. m_ui->setupUi(this);
    11.  
    12. // Cannot be set in Designer?
    13. setPixmap(QWizard::LogoPixmap, QPixmap(":/wizard/logo1.png"));
    14.  
    15. // Fields
    16. registerField("fileName*", m_ui->fileNameEdit);
    17. }
    18. ...
    To copy to clipboard, switch view to plain text mode 
    I can't get that concept to work. I can create a wizard with multiple pages but all widgets and pages are accessed from the ui object created by Qt Creator GUI application wizard. Do you have a sample that illustrates this?

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,620
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Can you create a custom multi-page QWizard with QtDesigner

    It is not clear exactly which thing "that concept" is referring to. You can build a QWizard two ways in Designer.

    One way, the one you seem to have used, builds the entire wizard as one ui object containing multiple pages. You only have the constructor of the QWizard to play with, but you can register fields in there for all pages of the wizard. All behaviour of the wizard is in the QWizard sub-class.

    The other way, like my example, is to create each QWizardPage as a separate Designer UI. You can then code the behaviour of each page in isolation. A Designer QWizard UI can then be built where each page in the wizard is simply a Promoted widget that invokes the relevant QWizardPage subclass.

  5. #5
    Join Date
    Oct 2012
    Location
    The land of pain (NY)
    Posts
    99
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default Re: Can you create a custom multi-page QWizard with QtDesigner

    Quote Originally Posted by ChrisW67 View Post
    It is not clear exactly which thing "that concept" is referring to. You can build a QWizard two ways in Designer.
    Referring to the method of sub-classing widgets. That's the 'concept'. This is the essence of what I am trying to do. The way I approached it seems to be the one by default project creation. That is, a wizard object that contains wizard pages all contained in a ui file. Am I wrong to assume that this is the default approach? What I think you are suggesting is an app that contains the underlying class structure that includes multiple ui files each having only one wizard page. If that is what your code sample suggested, it was jumping from what was posted.

    Is it possible to extend the default approach by having classes defined for each of the wizard pages defined in the main header file created by the app wizard? If so, I was having more than my share of challenges making that work.

    Thanks for the feedback. If you can post a sample of how such an approach you described is structured, I would greatly appreciate it.

  6. #6
    Join Date
    Oct 2012
    Location
    The land of pain (NY)
    Posts
    99
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default Re: Can you create a custom multi-page QWizard with QtDesigner

    Quote Originally Posted by ChrisW67 View Post
    It is not clear exactly which thing "that concept" is referring to. You can build a QWizard two ways in Designer.

    One way, the one you seem to have used, builds the entire wizard as one ui object containing multiple pages. You only have the constructor of the QWizard to play with, but you can register fields in there for all pages of the wizard. All behaviour of the wizard is in the QWizard sub-class.

    The other way, like my example, is to create each QWizardPage as a separate Designer UI. You can then code the behaviour of each page in isolation. A Designer QWizard UI can then be built where each page in the wizard is simply a Promoted widget that invokes the relevant QWizardPage subclass.
    Ok so I see that it appears to be more flexible having each QWizard page in its own ui file and then promoting each page to a new class so as to override the page's methods. Can you tell me how you created the wizard of the individual wizard pages? I AM using Qt designer as I mentioned for the visual layout of each page and their controls.

    Thanks

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,620
    Thanks
    13
    Thanked 1,592 Times in 1,520 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Can you create a custom multi-page QWizard with QtDesigner

    Here is an example. Notice that each page has a header and implementation file. Look at the wizard form in Designer and note that the two pages have a class that is not QWizardPage but a subclass of QWizardPage. This is the "promotion" feature. Right-click one of the pages in the object inspector and select "Promoted Widgets..." This is where you define the "promoted" classes that are available. You can also demote the page from the content menu.

    wiz.zip

  8. The following user says thank you to ChrisW67 for this useful post:

    astodolski (15th November 2012)

  9. #8
    Join Date
    Oct 2012
    Location
    The land of pain (NY)
    Posts
    99
    Thanks
    7
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Windows Android

    Default Re: Can you create a custom multi-page QWizard with QtDesigner

    Quote Originally Posted by ChrisW67 View Post
    Here is an example. Notice that each page has a header and implementation file. Look at the wizard form in Designer and note that the two pages have a class that is not QWizardPage but a subclass of QWizardPage. This is the "promotion" feature. Right-click one of the pages in the object inspector and select "Promoted Widgets..." This is where you define the "promoted" classes that are available. You can also demote the page from the content menu.

    wiz.zip
    Thanks VERY much!

Tags for this Thread

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.