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. Stack history from QStackedWidget
Forum Updated to NodeBB v4.3 + New Features

Stack history from QStackedWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 2 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.
  • M Offline
    M Offline
    Michelle02283
    wrote on last edited by
    #1

    I have a QStackWidget in my programm with many QWidgets inside and I need to save the history, which QWidgets were shown behind each other. How can I solve this problem?

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

      Hi,

      One possibility is to use a QVector. You'll append to it the index of the widget you are going to show each time you change it.

      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
      0
      • M Offline
        M Offline
        Michelle02283
        wrote on last edited by
        #3

        Hi,

        how works it? How can I append the index of the widget I am going to show each time I change it to the QVector?

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

          How are you going to change the widgets of your QStackWidget ?

          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
          • M Offline
            M Offline
            Michelle02283
            wrote on last edited by
            #5

            If a Buttons is released the widgets of my QStackWidget change. But I think the index of each Widget in the QStackWidgets doesn´t change right?

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

              No it doesn't however. When you change the front facing widget a.k.a current widget, the current index changes to match the one of the front facing widget.

              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
              • M Offline
                M Offline
                Michelle02283
                wrote on last edited by
                #7

                Can I write this with a SIGNAL and SLOT?

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

                  Can you show your current code ?

                  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
                  0
                  • M Offline
                    M Offline
                    Michelle02283
                    wrote on last edited by
                    #9

                    In Main:

                    QStackedWidget* stackedWidget = new QStackedWidget;
                    stackedWidget->addWidget(addAvailbaleFoodView);
                    stackedWidget->addWidget(errorview);
                    stackedWidget->addWidget(homeView);
                    stackedWidget->addWidget(errorWithSolutionView);
                    stackedWidget->showMaximized();

                    For example class AddAvailableFoodView:
                    AddAvailableFoodView::AddAvailableFoodView(QStackedWidget* stackedWidget, QStringList* stringList,SearchModel* searchmodel,DefinedFoodModel* definedFoodModel, QWidget parent) :
                    QWidget(parent)
                    {
                    _searchModel = searchmodel;
                    _definedFoodModel = definedFoodModel;
                    _wholeLayout = new QGridLayout;
                    MenuBarView
                    menuBar = new MenuBarView(stackedWidget,stringList,"Lebensmittel dem Vorrat hinzufügen");
                    _wholeLayout->setMenuBar(menuBar);
                    _wholeLayout->addWidget(createFirstInput());
                    setLayout(_wholeLayout);
                    }

                    On MenuBar there is a Button, which can show the Widget before ( "back"-button), but this MenuBar is on each Widget. If somebody pushes on the first Widget the "back"-button, I need the Widget which was shown before, but if somebody pushes the "back"-button on this Widget, I don´t want to get to the Widget, where I first pushed the "back"- button, I need to know where I was two Widgets before.

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

                      Then why not just compute the next or previous index ?

                      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
                      • M Offline
                        M Offline
                        Michelle02283
                        wrote on last edited by
                        #11

                        Sometimes there is not only one possibility which widget there was before

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

                          If your buttons just moves to the next or previous widget, then why the need of that history ?

                          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

                          • Login

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