Use fields in QtDesigner created wizards

  • I created a wizard using the QtDesigner component in Qt Creator. That is fine for simple wizards, as you can manipulate all pages in one go in a single .ui file. One thing I run into though, is that I don't see how to make a field mandatory in that setup. At least, not in an easy way. Both the documentented ways need subclassing of QWizardPage: one method reimplements isComplete(), the other is to use registerField. The latter method seems suitable for my setup, if only registerField was not protected. Any suggestions?

  • Well, I created a workaround, but it ain't pretty:

    class WizardPage: public QWizardPage
    WizardPage( QWidget* parent = 0 );
    void registerField(const QString &name, QWidget *widget, const char *property, const char *changedSignal);

    WizardPage::WizardPage(QWidget *parent):
    //intentionally empty

    void WizardPage::registerField(const QString &name, QWidget *widget, const char *property, const char *changedSignal)
    QWizardPage::registerField(name, widget, property, changedSignal);

    and then use widget promotion in Designer to use WizardPage instead of QWizardPage.

  • Andre: great post however I ran into small problem when using Qt Creator. I placed my wizard stuff (source,header, ui files) in a directory under the project directory which I'll call WIZARD for convenience. In this directory I placed the QWizard dialog and used the ui to design the form then as indicated above I subclassed QWizardPage and used widget promotion in order to access the registerField method.

    Unfortunately this failed as Qt Creator apparently assumes that the header file for the promoted widget is in the project directory not the WIZARD subdirectory. Ultimately I solved this by placing a symbolic link to the promoted header in the project directory (I don't want two independent copies of the header). As soon as the symbolic link was defined everything compiled and ran smoothly.

    Presumably there is a better way to accomplish the above but the symbolic link seems to work for me. Anyway I'm documenting my solution in case others run into the same problem.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.