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)
Forum Updated to NodeBB v4.3 + New Features

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.9k Views 3 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.
  • mrjjM mrjj

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

    cxamC Offline
    cxamC Offline
    cxam
    wrote on 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
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #7

      ok
      QStackedWidget seems right for a multipage application.

      cxamC 2 Replies Last reply
      0
      • mrjjM mrjj

        ok
        QStackedWidget seems right for a multipage application.

        cxamC Offline
        cxamC Offline
        cxam
        wrote on 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
        • mrjjM mrjj

          ok
          QStackedWidget seems right for a multipage application.

          cxamC Offline
          cxamC Offline
          cxam
          wrote on 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);
                                                          ^
          
          mrjjM 1 Reply Last reply
          0
          • cxamC cxam

            @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);
                                                            ^
            
            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on 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

            cxamC 1 Reply Last reply
            2
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on 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

              cxamC 1 Reply Last reply
              2
              • SGaistS SGaist

                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.

                cxamC Offline
                cxamC Offline
                cxam
                wrote on last edited by
                #12

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

                mrjjM 1 Reply Last reply
                0
                • mrjjM mrjj

                  @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

                  cxamC Offline
                  cxamC Offline
                  cxam
                  wrote on last edited by
                  #13
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • cxamC cxam

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

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #14

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

                    cxamC 1 Reply Last reply
                    1
                    • mrjjM mrjj

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

                      cxamC Offline
                      cxamC Offline
                      cxam
                      wrote on 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

                      • Login

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