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. QStackedWidget setCurrentIndex slot not showing on Signals&Slots editor (QtCreator)

QStackedWidget setCurrentIndex slot not showing on Signals&Slots editor (QtCreator)

Scheduled Pinned Locked Moved Unsolved General and Desktop
qstackedwidgetqtcreatorsignal & slotslot
15 Posts 3 Posters 6.8k Views
  • 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote on 23 Mar 2016, 22:12 last edited by
    #2

    Hi,

    How do you want to do that from a button ?

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

    C 1 Reply Last reply 24 Mar 2016, 13:16
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 23 Mar 2016, 23:58 last edited by
      #3

      hi
      the
      void setCurrentIndex(int index)
      wants an int to tell which page to show.
      The button clicked() or released() signal does not have
      int as a parameter so you cannot hook that signal to that slot as there
      is no way the button can send the index.

      However, the button can call a normal slot in main and
      there you can call setCurrentIndex with a index.

      1 Reply Last reply
      1
      • S SGaist
        23 Mar 2016, 22:12

        Hi,

        How do you want to do that from a button ?

        C Offline
        C Offline
        cxam
        wrote on 24 Mar 2016, 13:16 last edited by
        #4

        @SGaist you could imagine it as a setup wizard more or less, with 'next' or 'back' buttons

        M 1 Reply Last reply 24 Mar 2016, 13:17
        0
        • C cxam
          24 Mar 2016, 13:16

          @SGaist you could imagine it as a setup wizard more or less, with 'next' or 'back' buttons

          M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 24 Mar 2016, 13:17 last edited by
          #5

          @cxam
          just to be sure, u did see
          http://doc.qt.io/qt-5/qwizard.html
          which is for wizard type of interface.

          C 1 Reply Last reply 24 Mar 2016, 14:21
          0
          • M mrjj
            24 Mar 2016, 13:17

            @cxam
            just to be sure, u did see
            http://doc.qt.io/qt-5/qwizard.html
            which is for wizard type of interface.

            C Offline
            C Offline
            cxam
            wrote on 24 Mar 2016, 14:21 last edited by
            #6

            @mrjj said:

            http://doc.qt.io/qt-5/qwizard.html

            I said Setup Wizard as an example, what I exactly want is a main menu from where you can go to different interfaces, so I need buttons to go through pages. (This app is going to be running on a Raspberry Pi 2 using EGLFS)

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 24 Mar 2016, 17:58 last edited by
              #7

              ok
              QStackedWidget seems right for a multipage application.

              C 2 Replies Last reply 24 Mar 2016, 18:02
              0
              • M mrjj
                24 Mar 2016, 17:58

                ok
                QStackedWidget seems right for a multipage application.

                C Offline
                C Offline
                cxam
                wrote on 24 Mar 2016, 18:02 last edited by
                #8

                @mrjj So what I did so far is that when I clic the button it declares an int with the index number, now I could set the variable I declared as the index for my QStackedWidget right ?

                1 Reply Last reply
                0
                • M mrjj
                  24 Mar 2016, 17:58

                  ok
                  QStackedWidget seems right for a multipage application.

                  C Offline
                  C Offline
                  cxam
                  wrote on 24 Mar 2016, 18:24 last edited by
                  #9

                  @mrjj More or less like this:

                  
                  void MainWindow::on_Cambio1_clicked()
                  {
                      int cambio1;
                      cambio1 = 0;
                      void QStackedWidget::setCurrentIndex(cambio1);
                  }
                  

                  I don't know why but it comes up with this error:

                  error: invalid use of qualified-name 'QStackedWidget::setCurrentIndex'
                       int QStackedWidget::setCurrentIndex(cambio1);
                                                                  ^
                  
                  M 1 Reply Last reply 24 Mar 2016, 20:16
                  0
                  • C cxam
                    24 Mar 2016, 18:24

                    @mrjj More or less like this:

                    
                    void MainWindow::on_Cambio1_clicked()
                    {
                        int cambio1;
                        cambio1 = 0;
                        void QStackedWidget::setCurrentIndex(cambio1);
                    }
                    

                    I don't know why but it comes up with this error:

                    error: invalid use of qualified-name 'QStackedWidget::setCurrentIndex'
                         int QStackedWidget::setCurrentIndex(cambio1);
                                                                    ^
                    
                    M Offline
                    M Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on 24 Mar 2016, 20:16 last edited by mrjj
                    #10

                    @cxam
                    well i would expect something like
                    void MainWindow::on_Cambio1_clicked()
                    {
                    // int cambio1; <<< move to mainwinow.h in the class so all buttons have access to this "current-page"
                    cambio1++; // take next page//
                    ui->YourQStackedWidget->setCurrentIndex(cambio1);
                    }
                    set cambio1= 0 in mainwin constructor

                    A more clean way might be to use to functions
                    nextPage() and prevPage() in mainwindow
                    and the buttons just call that and it does the page switch back and forth.

                    please try this sample
                    https://www.dropbox.com/s/hpjtrr1xvo3lakw/stackedinteface.zip?dl=0

                    C 1 Reply Last reply 25 Mar 2016, 13:22
                    2
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 24 Mar 2016, 20:18 last edited by
                      #11

                      The error comes from the fact that your are trying to call a class method like it's a static method.

                      Even if you don't use QWizard, you can take a look at its implementation to get started.

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

                      C 1 Reply Last reply 24 Mar 2016, 22:58
                      2
                      • S SGaist
                        24 Mar 2016, 20:18

                        The error comes from the fact that your are trying to call a class method like it's a static method.

                        Even if you don't use QWizard, you can take a look at its implementation to get started.

                        C Offline
                        C Offline
                        cxam
                        wrote on 24 Mar 2016, 22:58 last edited by
                        #12

                        @SGaist @mrjj thank you very much for your help, I'll try that out and see how it goes.
                        Regards

                        M 1 Reply Last reply 25 Mar 2016, 14:52
                        0
                        • M mrjj
                          24 Mar 2016, 20:16

                          @cxam
                          well i would expect something like
                          void MainWindow::on_Cambio1_clicked()
                          {
                          // int cambio1; <<< move to mainwinow.h in the class so all buttons have access to this "current-page"
                          cambio1++; // take next page//
                          ui->YourQStackedWidget->setCurrentIndex(cambio1);
                          }
                          set cambio1= 0 in mainwin constructor

                          A more clean way might be to use to functions
                          nextPage() and prevPage() in mainwindow
                          and the buttons just call that and it does the page switch back and forth.

                          please try this sample
                          https://www.dropbox.com/s/hpjtrr1xvo3lakw/stackedinteface.zip?dl=0

                          C Offline
                          C Offline
                          cxam
                          wrote on 25 Mar 2016, 13:22 last edited by
                          #13
                          This post is deleted!
                          1 Reply Last reply
                          0
                          • C cxam
                            24 Mar 2016, 22:58

                            @SGaist @mrjj thank you very much for your help, I'll try that out and see how it goes.
                            Regards

                            M Offline
                            M Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on 25 Mar 2016, 14:52 last edited by
                            #14

                            @cxam
                            Yes, u can have buttons inside the pages if you want.
                            Works the same.

                            C 1 Reply Last reply 25 Mar 2016, 17:02
                            1
                            • M mrjj
                              25 Mar 2016, 14:52

                              @cxam
                              Yes, u can have buttons inside the pages if you want.
                              Works the same.

                              C Offline
                              C Offline
                              cxam
                              wrote on 25 Mar 2016, 17:02 last edited by
                              #15

                              @mrjj Hi! I managed to make everything just as I wanted, everything is going fine. The code example you sent me really did the trick. Thanks a lot.

                              1 Reply Last reply
                              0

                              11/15

                              24 Mar 2016, 20:18

                              • Login

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