[Solved] Using nextId() in linear wizard

  • I'm trying to create a linear wizard like this.

    this->setPage(Page_First, new PageReport());
    this->setPage(Page_Second, new PageSetting());
    this->setPage(Page_Final, new PageResult());

    Each pages in my wizard is added by using setPage(), which allow us to set the page ID

    I want to display the string "show result" on the next button in all wizard pages. I use the following source to achieve this goal, but it failed.

    if (Page_Final == nextId()) {
    setButtonText(QWizard::NextButton, QString("show result"));

    I checked the return value of nextId(). It always gives me -1. I know that I didn't implement the nextId() but I want to know which page would be the next. Can I get the next page ID in a linear wizard without implementing nextId()? Thank you

  • I know there are many alternatives to replace the text on the next button. But I want to use these pages to create many different wizards with different purposes. I don't want to take care with the page order or which page is the next. I just want to know "is the next page have the page ID Page_Final?"

    Thanks again.

  • I figured out why nextId() always returns -1. The reason is that I was using the nextId() in the constructor. Before the QWizardPage being inserted into QWizard, QWizard has no reason to know which page is the next page of current page.

    It's a stupid mistake. Sorry for disturbance.

Log in to reply

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