Solved QStackedWidget: How to check if the next widget should be shown
-
@JonB alright, so using that code and these lines:
LoginWidget *login = qobject_cast<LoginWidget*>(ui->stackedWidget->widget(0)); connect(login, SIGNAL(loginSuccesfull()), this, SLOT(showApp()));
should result in showApp to happen anytime the login was succesfull?
-
@hobbyProgrammer
I'm hoping so! Did you try it? -
@JonB yes and it didn't work. I tried debugging but I can't seem to find what's going wrong. It hits the code where the emit loginSuccessfull() is set, but it doesn't go to the SLOT where it's connected to and it ends in :
while (!d->exit.loadAcquire()) processEvents(flags | WaitForMoreEvents | EventLoopExec);
-
@hobbyProgrammer Did you make sure
connect(login, SIGNAL(loginSuccesfull()), this, SLOT(showApp()));
succeeded? And is this "login" the one you're actually showing?
-
@jsulm
it should be since I'm doing this:LoginWidget *login = qobject_cast<LoginWidget*>(ui->stackedWidget->widget(0));
-
@hobbyProgrammer And connect succeeded?
-
@jsulm I'm not sure, but I don't think so.
-
@hobbyProgrammer said in QStackedWidget: How to check if the next widget should be shown:
but I don't think so
Then it can't work.
Use new Qt5 connect syntax to be sure signal/slot are really connected:connect(login, &LoginWidget::loginSuccesfull, this, &MainWindow::showApp);
-
@jsulm yes thank you. That worked!
Thank you so much for you patience and help.
-
Because this is getting out of hand: