Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Adding a custom QWizardPage in QWizard



  • I add a QWizard into my project with 4 QWizardPages in it. I added one more QWizardPage grammatically into project and want to add this new page after first 2 QWizardPages in my QWizard created by QT Designer.

    How can I do that?


  • Qt Champions 2017

    I feel no direct way to do this. WHen you add the wizard pages, ids are fixed. You need do work-around do this. You can something like follows.

    @ QList<int> pageId = wizard.pageIds();
    QList<QWizardPage*> wList;
    int size = pageId.size();
    for (int i=0;i<size;i++){
    qDebug() << pageId.at(i);
    wList.append(wizard.page(i));
    wizard.removePage(i);
    }
    wList.insert(2,wiz4);

    for (int i=0;i<size+1;i++){
         wizard.setPage(i,wList.at(i));
    }@


  • Thanks for your reply. I asked this question for the following scenario, as I am unable to achieve this. I considered above question as a workaround for this scenario.

    I created a wizard using QWizard and added pages into it using QWizardPages.

    I need to load image on one of the QWizardPages [call it WizardPageAlpha].

    I created a subclass of QWizardPage[call it PromotedWizardClass] and promoted my WizardPageAlpha to this class as promoted widget.

    I am unable to access the the WizardPageAlpha widgets [a QLabel] from PromotedWizardClass.

    Regards,


  • Qt Champions 2017

    Yes, as I said there is no direct API do with page re-arrangement. That's why I specified the work-around as per the original question. I felt your current posted answer is slightly different from original post. I have not completely understood your second post. Let check this.



  • Thanks for prompt reply. This is what I needed to achieve:

    I created a wizard using QWizard and added pages into it using QWizardPages.

    I need to load image on one of the QWizardPages [call it WizardPageAlpha].

    I created a subclass of QWizardPage[call it PromotedWizardClass] and promoted my WizardPageAlpha to this class as promoted widget.

    I am unable to access the the WizardPageAlpha widgets [a QLabel] from PromotedWizardClass.

    After getting into this problem, I asked the above question as work around for this problem.

    My idea was that I would create a QWizardPage pragramatically and add the new QWizardPAge into its correct position in the QWizard.


Log in to reply