I'm using a 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 next
slot in my QWizard class; however, it seems this doesn't work. The program still went into the original next
slot in the parent QWizard class instead of the one I implemented.
Is this because this next
slot is virtual protected? How can I do some things after the next button is clicked?
The header file of my QWizard class follows. By the way, the accept
signal works fine as what 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 wizard instance via QtCreator's wizard (Ha XD)
The code is as follows:
PrimerWizard* pW = new PrimerWizard(this);
pW->exec();
And the signal-slot connection of next
is created by QtCreator, I cannot find where it's actually connected. I think the connection is built in ui_PrimerWizard.h by this function:
QMetaObject::connectSlotsByName(PrimerWizard);
The next
slot cannot be overwritten. However, the validatePage
function for QWizardPage can. This function will be called when the "Next" or "Finish" button is clicked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With