Show Widget B if an event in Widget A occurred ?
Hello Folks,
I have Widgets A and B. Lets say Widget A has a push button to assign x1=true, while it is initially is initialized to false.
What i want to do is show Widget A, then after pressing the push button Widget A hides and Widget B appears.
I 'think' I am not really understanding the loop event sequence. My code is as the following:
Code:
#include <QtGui/QApplication>
#include "mainwindow.h"
#include "startupscreen.h"
int main(int argc, char *argv[])
{
StartUpScreen startup;
startup.show();
if (startup.x1)
{
MainWindow w;
w.show();
startup.hide();
}
return a.exec();
}
Thank you very much,
Re: Show Widget B if an event in Widget A occurred ?
Why you don't open the MainWindow inside the pushbutton event?
Something like:
Code:
MainWindow * w = new MainWindow(0); // in the constructor, paarent should be zero, so we can delete StartUpScreen without problems.
w->show();
deleteLater();
Hth.
Re: Show Widget B if an event in Widget A occurred ?
w goes out of scope, so you don't have a chance to see it.
---
sorry, actually I paid more attention to the code rather than your question :o
You should wait and react on the push button click, because this
Code:
startup.show();
if (startup.x1)
...
does not give the main event loop a chance to start before you check the variable.
Instead of assigning a variable, create and show the second window.
Re: Show Widget B if an event in Widget A occurred ?
I don't think so...
StartUpScreen will appear just when we enter the "a.exec()", which is after the validation of x1....