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. QWizardPage::nextId called way to often
Forum Updated to NodeBB v4.3 + New Features

QWizardPage::nextId called way to often

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 442 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.
  • HoMaH Offline
    HoMaH Offline
    HoMa
    wrote on last edited by
    #1

    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
    
    JonBJ 1 Reply Last reply
    0
    • HoMaH HoMa

      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
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #3

      @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 when nextId() returns -1.

      ?

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

        Hi,

        Which version of Qt ?
        Which OS ?

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

        HoMaH 1 Reply Last reply
        0
        • HoMaH HoMa

          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
          
          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #3

          @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 when nextId() returns -1.

          ?

          HoMaH 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            Which version of Qt ?
            Which OS ?

            HoMaH Offline
            HoMaH Offline
            HoMa
            wrote on last edited by
            #4

            @SGaist latest version of Qt, I work on Windows with mingGw

            1 Reply Last reply
            0
            • JonBJ JonB

              @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 when nextId() returns -1.

              ?

              HoMaH Offline
              HoMaH Offline
              HoMa
              wrote on last edited by
              #5

              @JonB that's a good thought ... Thanks. This would explain at least one of the calls :)

              1 Reply Last reply
              0

              • Login

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