Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. virtual function validateCurrentPage in QWizard isn't called upon Finish

virtual function validateCurrentPage in QWizard isn't called upon Finish

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 892 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RanH
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      RanH
      wrote on last edited by
      #4

      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

      1 Reply Last reply
      2
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        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 ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • R Offline
          R Offline
          RanH
          wrote on last edited by RanH
          #3

          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;
          };
          
          1 Reply Last reply
          0
          • R Offline
            R Offline
            RanH
            wrote on last edited by
            #4

            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

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved