Solved QWizardPage::nextId called way to often
-
Hi there!
I just learned from this code, that QWizardPage::nextId() is not called for the final page. This seams OK, because there is no "next" on the final page but only "finish".
However: What I don't understand:
nextId is called twice (!) before each page is displayed. Is this a bug? Or can you explain why?Header:
enum { FIRST = 0, SECOND = 1 }; class firstP : public QWizardPage { Q_OBJECT; public: firstP(QWidget* p) : QWizardPage(p){} void initializePage() override; bool validatePage() override; int nextId() const override; }; class secP : public QWizardPage { Q_OBJECT; public: secP(QWidget* p) : QWizardPage(p){} void initializePage() override; bool validatePage() override; int nextId() const override; }; class wiz : public QWizard { Q_OBJECT; public: wiz(QWidget* p); };
cpp:
void secP::initializePage() { qInfo() << "init of second Page"; } bool secP::validatePage() { qInfo() << "validate second Page"; return false; } int secP::nextId() const { qInfo() << "nextId from second Page"; return -1; } wiz::wiz(QWidget* p) : QWizard(p) { setPage(FIRST, new firstP(p)); setPage(SECOND, new secP(p)); }
output:
init of first Page nextId from first Page nextId from first Page validate first Page nextId from first Page init of second Page nextId from second Page nextId from second Page validate second Page
-
@HoMa
My thought would be: to decide about enablement of Next/Finish buttons? If you read through https://doc.qt.io/qt-5/qwizardpage.html#details, it says e.g.By default,
isFinalPage()
is true only whennextId()
returns -1.?
-
Hi,
Which version of Qt ?
Which OS ? -
@HoMa
My thought would be: to decide about enablement of Next/Finish buttons? If you read through https://doc.qt.io/qt-5/qwizardpage.html#details, it says e.g.By default,
isFinalPage()
is true only whennextId()
returns -1.?
-
@SGaist latest version of Qt, I work on Windows with mingGw
-
@JonB that's a good thought ... Thanks. This would explain at least one of the calls :)