Multiple Widgets
-
To vague to answer with certainty. Are those 2 QMainWindows? Is one of them a dialog, message box or else?
In general, in your main routine (int main()), you can show the first widget first, and then when it finishes (you can destroy it, or just hide) you can show the other one. There are also other ways to do it, but I can't really say anything more concrete before you give more details on your situation.
-
If you create project by QtCreator wizzard so look at main.cpp file:
@#include <QtGui/QApplication>
#include "widget.h"int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Widget w;
w.show();return a.exec();
}@
in line 7 creation of Widget object and at line 8 its shows. Other widget you can show from this one.
But if you tell as what you try to do then you can get more useful answer. -
[quote author="zEp0" date="1360512318"] How can I tell QT, which one he should run at first?
Thank you![/quote]It will be the one instantiated in your main() function. Widgets are like nesting dolls, you can put widgets inside widgets. So if your second widget needs to show from the first widget, all you need to do is put it in there, just like you would but a button, a check box or any other widget derived component. You can of course always show the second widget conditionally.
-
It's not the best solution but it is one, because I don't know your exact usage of your application.
Make your both QWidgets to QDialog (.i.e: "class A : public QWidget" to "class A : public QDialog" ) and then use the exec() function instead of show().
Like:[code]int main(int argc, char *argv[])
{
QApplication a(argc, argv);
WDialog1 w1;
w1.exec();
WDialog2 w2;
w2.exec();return a.exec();
}[/code]
It will first start the w1 instance and when you close it, it will start the next instance (w2).