Important: Please read the Qt Code of Conduct -

[Solved] advance to next page would not work in the last page of wizard

  • I wrote a wizard based on QWizardPage. It contains many QWizardPages.

    I was using calling this->wizard()->next() to automatically advance to next page in QWizardPage (the this pointer pointed to QWizardPage). It works well in all pages except the last page. In the last page, this->wizard()->next() does not work and it gives me no error message. It still stayed in the last page. The validation validatePage() was called and I have made sure the return value was true.

    Can I make my last wizard page automatically finish its wizard flow? Is there any way to finish the wizard automatically?

  • Why do you assume the next function is the same as the finish function?
    Note that you can even show buttons for both at the same time, when you have some optional steps that a user may or may not want to complete.

    I assume you know which page is the finish page, and you can easily just call accept() instead from that page.

  • I want my users can input some data and they don't have to press next button to advance to the next page. What I did for this is to connect textChanged() to my validation function. The input was made by bar code scanner so I don't have to worry about the input error. I just want to speed up the form filling.

    I have tried calling accept() to finish the last page in my wizard. but it still not work. Did I miss anything?


    I just simply call the member function accept() of my wizard.

  • I would have expected calling accept like you do would work. If it doesn't, I'm not sure what's wrong.

  • I think I made some stupid mistake. The accept() works well. Maybe there was something wrong with my environment.

    The reason that the next() does not work with the final page is the return value of nextId().

    void QWizard::next()

    if (d->current == -1)
    if (validateCurrentPage()) {
        int next = nextId();
        if (next != -1) {
            if (d->history.contains(next)) {
                qWarning("QWizard::next: Page %d already met", next);
            if (!d->pageMap.contains(next)) {
                qWarning("QWizard::next: No such page %d", next);
            d->switchToPage(next, QWizardPrivate::Forward);


    If the return value of nextId() was -1, It would not do anything. Just like the QWizard reference said: This is equivalent to pressing the Next or Commit button. Clicking the finish button is not the same as next button

Log in to reply