Placing an object into a specific page of a QStackedWidget
-
Hi. I've got quite a few widgets that I would like to place on a particular page of a QStackedWidget. However, I have been having trouble.
Every time I switch to another page of the QStackedWidget and then pull back to the original page, the widgets are not displayed on the ui.
This is how I created and set up the aforementioned widgets.
QWidget *lineParent = ui->stackedWidget; QLabel *REEEEE = new QLabel(lineParent); REEEEE->setText("AHHHHHHHH"); REEEEE->move(100,100); //Build the main line. QFrame *frontLine = new QFrame(lineParent); frontLine->setStyleSheet(markerStyle); frontLine->setGeometry(X, Y, SPLITLINEWIDTH, SPLITLINEHEIGHT); QString labelText = "Initial Temp";I have not been able to locate a function that specifically places the widget on any specific page of the QStackedWidget (I found insertWidget but that doesn't seem to have placed the widget in a visible place). I am not sure how to proceed. Please let me know if more information is required.
-
Hi. I've got quite a few widgets that I would like to place on a particular page of a QStackedWidget. However, I have been having trouble.
Every time I switch to another page of the QStackedWidget and then pull back to the original page, the widgets are not displayed on the ui.
This is how I created and set up the aforementioned widgets.
QWidget *lineParent = ui->stackedWidget; QLabel *REEEEE = new QLabel(lineParent); REEEEE->setText("AHHHHHHHH"); REEEEE->move(100,100); //Build the main line. QFrame *frontLine = new QFrame(lineParent); frontLine->setStyleSheet(markerStyle); frontLine->setGeometry(X, Y, SPLITLINEWIDTH, SPLITLINEHEIGHT); QString labelText = "Initial Temp";I have not been able to locate a function that specifically places the widget on any specific page of the QStackedWidget (I found insertWidget but that doesn't seem to have placed the widget in a visible place). I am not sure how to proceed. Please let me know if more information is required.
@Dummie1138 said in Placing an object into a specific page of a QStackedWidget:
QLabel *REEEEE = new QLabel(lineParent);
This is not how QStackedWidget is used. Please take a look at documentation: https://doc.qt.io/qt-6/qstackedwidget.html
There is a simple example which shows how to add widgets to different pages:QWidget *firstPageWidget = new QWidget; QWidget *secondPageWidget = new QWidget; QWidget *thirdPageWidget = new QWidget; QStackedWidget *stackedWidget = new QStackedWidget; stackedWidget->addWidget(firstPageWidget); stackedWidget->addWidget(secondPageWidget); stackedWidget->addWidget(thirdPageWidget);