Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Override next button functionality in QWizardPage



  • Hi,

    I want to make some things when the next or back button are pressed in a QWizardPage.
    But I don't know how to override the functionality of that buttons.

    I saw in the Qt Documentation page the function nextId: https://doc.qt.io/qt-5/qwizard.html#nextId
    But that's only for indicate the order page in non-linear wizards.

    Some suggestion?

    Thanks



  • @Carlavilla
    Unless someone knows a better way, could you handle the QWizard::currentIdChanged(int id) signal?

    Or, if you have derived your own class from base QWizard (always a good idea), you can just override QWizard::next() --- maybe do your own stuff, then call base QWizard::next(), depending on what you want to do?



  • I've done this:

    This is my header file:

    class MachineNamePage: public QWizardPage {
        Q_OBJECT
    
        public:
            ......
        signals:
           ......
        public slots:
            void selectOS(int OSSelected);
            void next();
    
        protected:
    
        private:
            ......
    };
    

    This is my source file:

    MachineNamePage::MachineNamePage(QWidget *parent) : QWizardPage(parent) {
    ......
    }
    
    void MachineNamePage::next() {
        qDebug() << "Next";
    }
    

    But I don't know how to make the QWizardPage execute the code inside MachineNamePage::next()



  • I solve the problem using the 'validatePage' function.

    bool MachineNamePage::validatePage() {
    
        return true;
    }
    

Log in to reply