Solved virtual function validateCurrentPage in QWizard isn't called upon Finish
-
I have a QWizard, and I override validateCurrentPage() in order to perform actions before passing to the next page. This function is working well on all pages, except for the last page - where Finish is pressed. the accept() function is called, but not validateCurrentPage().
Judging by Qt docs:
This virtual function is called by QWizard when the user clicks Next or Finish to perform some last-minute validation
this function was supposed to be called just like in any other page.Why isn't it working?
-
Alright I figured out the problem...
Because I did not perform QDialog::accept(), and my accept was called, it did not proceed to the validateCurrentPage() function -
Hi and welcome to devnet,
What version of Qt are you using ?
On what platform ?Can you provide a minimal compilable example that shows that behaviour ?
-
I am using Qt 5.5.1 on windows 7 64bit,
I tried to reduce the code to its minimal interesting parts;
I should also mention I tried to implement the validatePage on the page and it didn't reach it either.class MyQWizard : public QWizard { Q_OBJECT public: MyQWizard(QWidget *parent = 0); ~MyQWizard(); virtual bool validateCurrentPage() override; virtual void accept() override; private: Ui::MyQWizard ui; }; MyQWizard::MyQWizard(QWidget *parent) : QWizard(parent) { ui.setupUi(this); setPage(static_cast<int>(MyPageIndexes::INTRO_PAGE_IDX), new IntroPage(this)); setPage(static_cast<int>(MyPageIndexes::OPEN_DOOR_PAGE_IDX), new OpenDoorPage(this)); setPage(static_cast<int>(MyPageIndexes::CLOSE_DOOR_PAGE_IDX), new CloseDoorPage(this)); setWindowTitle(tr("My Wizard")); } void MyQWizard::accept() { } bool MyQWizard::validateCurrentPage() { switch (currentId()) { case static_cast<int>(MyPageIndexes::INTRO_PAGE_IDX): break; case static_cast<int>(MyPageIndexes::OPEN_DOOR_PAGE_IDX): break; case static_cast<int>(MyPageIndexes::CLOSE_DOOR_PAGE_IDX): //DO SOMETHING break; } return true; } class CloseDoorPage : public QWizardPage { Q_OBJECT public: CloseDoorPage(QWidget *parent = 0); private: QLabel *label; };
-
Alright I figured out the problem...
Because I did not perform QDialog::accept(), and my accept was called, it did not proceed to the validateCurrentPage() function