How can I overwrite the “next” slot in QWizard?

I use the QWizard class, which contains several QWizardPage. For some pages, I need to do something when the "Next" button is clicked.

I tried to overwrite the slot nextin my QWizard class; however, this does not seem to work. The program still ended up in the original slot nextin the parent QWizard class instead of the one I implemented.

Is it because this nextslot is virtually protected? How can I do some action after clicking the next button?


The following is the header file of my QWizard class. By the way, the signal acceptworks fine, as I expected.

#ifndef PRIMERWIZARD_H
#define PRIMERWIZARD_H

#include <QWizard>

namespace Ui {
    class PrimerWizard;
}

class PrimerWizard : public QWizard {
    Q_OBJECT
public:
    PrimerWizard(QWidget *parent = 0);
    ~PrimerWizard();
protected slots:
    void next();
    void accept();

protected:
    void changeEvent(QEvent *e);

private:
    Ui::PrimerWizard *ui;
};

#endif // PRIMERWIZARD_H

I create a new instance of the wizard using the QtCreator wizard (Ha XD)

The code is as follows:

PrimerWizard* pW = new PrimerWizard(this);
pW->exec();

next QtCreator, , . , ui_PrimerWizard.h :

QMetaObject::connectSlotsByName(PrimerWizard);
+5
1

next . validatePage QWizardPage . "" "".

+2

All Articles