If I understand you correctly, you want one application that either shows two different QMainWindows from start-up, or have one create the other when requested (dialog style). This is where I'd start:
- Build main window A in Designer. Let's call it MyMainA.
- Build main window B in Designer with a different layout or whatever. Let's call this class MyMainB.
Now you have two classes that, when instantiated, create a main window. If you want both to show from application start then:
#include <QApplication>
#include "mymaina.h"
#include "mymainb.h"
int main(int argc, char *argv[])
{
MyMainA mainA;
MyMainB mainB;
mainA.show();
mainB.show();
return app.exec();
}
#include <QApplication>
#include "mymaina.h"
#include "mymainb.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyMainA mainA;
MyMainB mainB;
mainA.show();
mainB.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
or if MyMainA should launch MyMainB then edit the MyMainA class code to respond to a button click (or whatever) and then
void MyMainA::on_aButton_clicked() {
MyMainB *mb = new MyMainB(this);
mb->show();
}
void MyMainA::on_aButton_clicked() {
MyMainB *mb = new MyMainB(this);
mb->show();
}
To copy to clipboard, switch view to plain text mode
If you already have MyMainB built in another project (that's what I think you mean by both in seperate directories) you could copy its source files into the new project and add them to the project's pro file. (Duplicating code like this is not ideal but that's another story). If you simply stored MyMainB source elsewhere when you built it in the current project then Qt Creator should have put correct paths in the pro file, and it should just build.
Bookmarks