qstackedwidget timeout
-
Hi,
I created a qstackedwidget (3 pages) using qt designer. My goal is page 1 leads the user to page3. When the user clicks a button on page 1, page 2 will show a message for 10-15 seconds then the user is redirected to page 3. I can't figure out how to implement it nor can I find an example online I can study.
Would appreciate your assistance!
-
Hi
you can use a timer which you connect to your slot.
When you press button 1, you start timer and switch to page 2
(showing the message)
then when timer fires its timeout() signal, to your slot, then
you simply go to page 3. -
I'm just starting to learn Qt and get involved in C++ programming again. I followed your advise to the best of my ability but ran through an error.
In mainwindow.h I added void move2page3();
private slots: void on_pushButton_clicked(); void move2page3();
in mainwindow.cpp I added
void MainWindow::on_pushButton_clicked() { QTimer::singleShot(200, this, SLOT(move2page3())); ui->stackedWidget->setCurrentIndex(1); } void MainWindow::move2page3() { ui->stackedWidget->setCurrentIndex(2); }
When I try to run the app, I get the following error:
C:\3pages\mainwindow.cpp:-1: In member function 'void MainWindow::on_pushButton_clicked()':
C:\3pages\mainwindow.cpp:18: error: incomplete type 'QTimer' used in nested name specifier
QTimer::singleShot(200, this, SLOT(move2page3()));
^First, am I following your advice or did I miss anything?
Second, what am I doing wrong?