Important: Please read the Qt Code of Conduct -

QWizard - Dynamic Start Page

  • I am working on creating a login wizard which has the following pages:

    1. Welcome Page
    2. Set Locale Page
    3. Choose Options Page
    4. etc.

    When the wizard is initialized, a check is performed to see if a configuration file exists. This file will contain the previously set locale, so I would like to start at page 3 if this is the case. If no file exists, it will start at page 1. The issue with setting the startId to page 3 is that the QWizard will not allow a user to go back if they wanted to change their locale.

    Is there any way to set the start page to page 3 and allow the user to go back if desired? Or is this going to need to be changed to a QStackedWidget with its own start/previous/next logic built?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    From the top of my head, one thing you can try is to call QWizard's next slot twice to go the 3 page if the local has been set. I think it should behave the same as if the user clicked on the next button.

  • @SGaist I've tried this after setting the startId, but the QWizard's currentId is set to -1 at this point so it just returns out of the next() call without doing anything unfortunately.

  • Lifetime Qt Champion

    Why set the startId ?

  • @SGaist I suppose it doesn't matter if I don't set the startId, it'll default to the first page added to the QWizard anyway. I originally had logic to check if the config exists and then set the startId to page 3, otherwise, set it to page 1. When it is set to page 3, the choices page is the first page displayed which is nice, but the back button is disabled.

    I've tried forcing an enable on the QWizard's back button, but since the QWizard page history does not have anything in it, the button remains disabled.

    I'm starting to think the QStackedWidget approach will suit my needs...


    Converted my QWizard to a QDialog and the QWizardPages to QWidgets. Added a QStackedWidget to the QDialog and added each page as its own widget. I have better control of the wizard flow which suits my needs.


Log in to reply