qtqt5qwidgetqwizardqwizardpage

How can I go to a specific QWizard page number?


Qt 5, QWizard

Hello! I have checked some answers on that subject but still can't quite figure that out. Here is the idea that I want to do:

I want to create a button group navigate between QWizard pages.

For example, at the top of my QWizard I have:

enter image description here

On button click, I get an id, the same as pages id, and I want to show the user page with this id.

I try to call:

this->page(pageId)->show(); 

Of course, it's not correct! I see addPage(), page(), and pageAdded(). but it is has not set method.

Сertainly I can analyze my id, get current page number, and called this->back(); or next method, but maybe it has the simplest method, that I don't know?

void StartupWizard::OnPageNumMove(int pageIdToMove)
{
    if(currentId()==pageIdToMove)
    {
        return;
    }
    else
    {
        if(currentId()<pageIdToMove)
        {
            while (pageIdToMove!=currentId())
            {
                this->next();
            }
        }
        else
        {
            while (pageIdToMove!=currentId())
            {
                this->back();
            }
        }
    }
}

Solution

  • As of Qt 6.4.2 you can call QWizard::setCurrentId to

    Set currentId to id, without visiting the pages between currentId and id.