How to go back 2 Wizardpages on a QWizard



  • Hi again! I'm back with my QWizard and its QWizardPAges...

    I have the next pages for example: WP1 > WP2 > WP3 > WP4 Bien WP1 the first and WP4 the last one, my question is the next:
    If user is in WP3 and hits the Back button, it has to go to WP1, never WP2 again.... but I can't achieve this... how should I do the QWizard Back Button make that in that case┬┐?

    Thank you so much


  • Lifetime Qt Champion

    Hi,

    One thing you could try is to use you own back button using QWizard::setButton and connect it to a slot where you can handle that use case by setting the nextId to one and call next by hand.

    Hope it helps



  • @SGaist said:

    One thing you could try is to use you own back button using QWizard::setButton and connect it to a slot where you can handle that use case by setting the nextId to one and call next by hand.

    Sorry for the late reply but something more important came before... This is my code:

    connect(wizard(), SIGNAL(customButtonClicked(int)),this, SLOT(GoBackToMenu(int)));
    wizard()->button(QWizard::CustomButton1)->setText(QString::fromUtf8("Back")); 
    wizard()->button(QWizard::CustomButton1)->setVisible(true);
    
    void WPConfigs12::GoBackToMenu(int i)
    {
        if (i==6) // i =6 is custombuttton1
        {
            wizard()->next();
        }
    }
    

    And then, ofc as wizard has already met the 2 WP back I need to do something like:

    bool BaseWizard::validateCurrentPage()
    {
        qDebug() << " estoy en validatecurrentpage back() " ;
    
        if( currentPage() == page( WP3) )
        {
            if( ! currentPage()->validatePage() )
           {
                while( currentPage() != page( WP1) )
                {
                     back();
                }
                return( false );
            }
            return( true );
       }
    }
    

    Normally this one works fine for me but this time does something strange:

    I start in WP1, then show WP2 (the one I want to hide when doing Back), and then show WP3.
    After that I click Back and it goes PERFECTLY to WP1 (which is the behaviour I am looking for) BUT if I click next again then it does: WP1>WP2>WP1 and if I click next again it does: WP1>WP2>WP3>WP2>WP3>WP2 >WP2....

    so.. any idea about how to go back and not having those problems?
    Thank you!


  • Lifetime Qt Champion

    I was thinking more about an adaptation of the Non Linear Wizard example



  • @SGaist Well, what I have is this type of 'non linear' wizard.. in fact I started with that example :D But I don't get how should I do it... If you say it for the BaseWizard::validateCurrentPage() then I don't know how to do it with other way.... could you please explain me what you are thinking more exactly? Thanks!


  • Lifetime Qt Champion

    I was thinking about reimplementing nextId so that when you click on the "Back" button you reroute to the page you want then call next()


Log in to reply
 

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