I have a QStackedWidget with 2 pages; on the second page I have a label. How can I change the label text, e.g. pressing a button? I can't set the text programmatically because it can't find the widget I have created in the .ui designer
This is my mainwindow.cpp
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
ui->stackedWidget->setCurrentIndex(0);
}
void MainWindow::on_changeText_clicked()
{
ui->stackedWidget->myLabel->setText("A"); //can't do this, it doesn't find "myLabel"
ui->myLabel->setText("A"); //it finds "myLabel" but the text doesn't change
}
question from:https://stackoverflow.com/questions/65945351/access-widget-inside-qstackedwidget-in-qt-creator