PDA

View Full Version : Can you create a custom multi-page QWizard with QtDesigner



amoswood
14th May 2009, 16:21
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.

ChrisW67
10th July 2009, 02:14
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:

#include <QFileDialog>

#include "importfilepage.h"
#include "ui_importfilepage.h"

ImportFilePage::ImportFilePage(QWidget *parent) :
QWizardPage(parent),
m_ui(new Ui::ImportFilePage)
{
m_ui->setupUi(this);

// Cannot be set in Designer?
setPixmap(QWizard::LogoPixmap, QPixmap(":/wizard/logo1.png"));

// Fields
registerField("fileName*", m_ui->fileNameEdit);
}
...

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.

astodolski
25th October 2012, 20:45
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:

#include <QFileDialog>

#include "importfilepage.h"
#include "ui_importfilepage.h"

ImportFilePage::ImportFilePage(QWidget *parent) :
QWizardPage(parent),
m_ui(new Ui::ImportFilePage)
{
m_ui->setupUi(this);

// Cannot be set in Designer?
setPixmap(QWizard::LogoPixmap, QPixmap(":/wizard/logo1.png"));

// Fields
registerField("fileName*", m_ui->fileNameEdit);
}
...



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?

ChrisW67
25th October 2012, 23:17
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.

astodolski
26th October 2012, 02:35
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.

astodolski
14th November 2012, 20:57
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

ChrisW67
14th November 2012, 22:46
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.

8416

astodolski
15th November 2012, 14:22
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.

8416

Thanks VERY much!