Unsolved Stack history from QStackedWidget
-
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?
-
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.
-
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?
-
How are you going to change the widgets of your QStackWidget ?
-
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?
-
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.
-
Can I write this with a SIGNAL and SLOT?
-
Can you show your current code ?
-
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.
-
Then why not just compute the next or previous index ?
-
Sometimes there is not only one possibility which widget there was before
-
If your buttons just moves to the next or previous widget, then why the need of that history ?