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. Issue with Signals and Slots & QWizard
Qt 6.11 is out! See what's new in the release blog

Issue with Signals and Slots & QWizard

Scheduled Pinned Locked Moved Solved General and Desktop
7 Posts 3 Posters 1.9k Views 2 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.
  • A Offline
    A Offline
    AhmedAlshawi
    wrote on last edited by AhmedAlshawi
    #1

    Hi,

    I have set up a QWizard in the same way as Qt licensewizard example. I launch the wizard from my mainWindow.cpp using wizard.exec;

    Within my wizard I want to pass information back over to my MainWindow. To do this I have done:


    mainwindow.cpp

    myWizard wizard;
    connect(&wizard, &myWizard::sendTheData, this, &MainWindow::recieveTheData);
    wizard.exec;
    

    The problem I am having is that I am not sure how emit the myWizard::sendTheData signal when the user presses Done to complete the wizard.

    I have tried to do this:

    void finalPage::setVisible(bool visible)
    {
       QWizardPage::setVisible(visible);
       connect(wizard()->button(QWizard::FinishButton), &QPushButton::clicked, wizard(), &myWizard::sendTheData );
    }
    

    but this gives me "no matching member function for call to 'connect'"


    I also tried, in mainWindow.cpp to connect a signal that is sent from the finalPage class to a slot in mainWindow, like below, but that also doesn't work.

    myWizard wizard;
    finalPage fp;
    connect(&fp, &finalPage::sendTheData, this, &MainWindow::recieveTheData);
    wizard.exec;
    

    Any help would be appreciated thank you!

    Pl45m4P 1 Reply Last reply
    0
    • A AhmedAlshawi

      Hi,

      I have set up a QWizard in the same way as Qt licensewizard example. I launch the wizard from my mainWindow.cpp using wizard.exec;

      Within my wizard I want to pass information back over to my MainWindow. To do this I have done:


      mainwindow.cpp

      myWizard wizard;
      connect(&wizard, &myWizard::sendTheData, this, &MainWindow::recieveTheData);
      wizard.exec;
      

      The problem I am having is that I am not sure how emit the myWizard::sendTheData signal when the user presses Done to complete the wizard.

      I have tried to do this:

      void finalPage::setVisible(bool visible)
      {
         QWizardPage::setVisible(visible);
         connect(wizard()->button(QWizard::FinishButton), &QPushButton::clicked, wizard(), &myWizard::sendTheData );
      }
      

      but this gives me "no matching member function for call to 'connect'"


      I also tried, in mainWindow.cpp to connect a signal that is sent from the finalPage class to a slot in mainWindow, like below, but that also doesn't work.

      myWizard wizard;
      finalPage fp;
      connect(&fp, &finalPage::sendTheData, this, &MainWindow::recieveTheData);
      wizard.exec;
      

      Any help would be appreciated thank you!

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by Pl45m4
      #2

      @AhmedAlshawi

      Do you have the signals declared in your headers?

      You need something like

      signals:
         void sendTheData();
      

      in your finalPage.h


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

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

        Hi,

        You might be over-engineering it.

        You can simply give getters to your wizard and retrieve the data from it after calling exec. A wizard rarely needs signal and slots to pass data.

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

        A 1 Reply Last reply
        1
        • Pl45m4P Pl45m4

          @AhmedAlshawi

          Do you have the signals declared in your headers?

          You need something like

          signals:
             void sendTheData();
          

          in your finalPage.h

          A Offline
          A Offline
          AhmedAlshawi
          wrote on last edited by
          #4

          @Pl45m4

          Yeah definitely. Mywindow.h and mywizard.h both have the slot/signal.

          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            You might be over-engineering it.

            You can simply give getters to your wizard and retrieve the data from it after calling exec. A wizard rarely needs signal and slots to pass data.

            A Offline
            A Offline
            AhmedAlshawi
            wrote on last edited by
            #5

            @SGaist thanks for this direction.

            Could you share/link me to an example to show what you mean? I’ve not heard the term “getter” before 😅

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

              QWizard::currentPage is a getter for example.

              A getter is method that returns a value, pointer, etc. It might be implemented in tandem with a setter.

              Qt read/write properties have one of each for example.

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

              A 1 Reply Last reply
              0
              • SGaistS SGaist

                QWizard::currentPage is a getter for example.

                A getter is method that returns a value, pointer, etc. It might be implemented in tandem with a setter.

                Qt read/write properties have one of each for example.

                A Offline
                A Offline
                AhmedAlshawi
                wrote on last edited by
                #7

                @SGaist I was way over-engineering it!

                I just used registerField("fieldName", widget) for each of the fields in each of the QWizardPages that I wanted to take across to mainWindow. Then after wizard.exec in mainWindow, I just called QVariant item1 = wizard.field("fieldName"). Then I converted each of the QVariants to the types I wanted :)

                Works a charm. Thank you!!

                1 Reply Last reply
                1

                • Login

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