Take the 2-minute tour ×

I'm about to start on a large Qt application, which is made up of smaller components (groups of classes that work together). For example, there might be a dialog that is used in the project, but should be developed on its own before being integrated into the project. Instead of working on it in another folder somewhere and then copying it into the main project folder, can I create a sub-folder which is dedicated to that dialog, and then somehow incorporate it into the main project?

share|improve this question
add comment

3 Answers

up vote 13 down vote accepted

Here is what I would do. Let's say I want the following folder hierarchy :


will containt the files for the whole application.


will contain the files for the standalone dialogbox which will be eventually part of the whoel application.

I would develop the standalone dialog box and the related classes. I would create a Qt-project file which is going to be included. It will contain only the forms and files which will eventually be part of the whole application.

File DummyDlg.pri, in /MyWholeApp/DummyDlg/ :

# Input
FORMS += dummydlg.ui
HEADERS += dummydlg.h
SOURCES += dummydlg.cpp

The above example is very simple. You could add other classes if needed.

To develop the standalone dialog box, I would then create a Qt project file dedicated to this dialog :

File DummyDlg.pro, in /MyWholeApp/DummyDlg/ :



# Input
SOURCES += main.cpp

As you can see, this PRO file is including the PRI file created above, and is adding an additional file (main.cpp) which will contain the basic code for running the dialog box as a standalone :

#include <QApplication>
#include "dummydlg.h"

int main(int argc, char* argv[])
    QApplication MyApp(argc, argv);

    DummyDlg MyDlg;
    return MyApp.exec();

Then, to include this dialog box to the whole application you need to create a Qt-Project file :

file WholeApp.pro, in /MyWholeApp/ :

DEPENDPATH += . DummyDlg


# Input
FORMS += OtherDlg.ui
HEADERS += OtherDlg.h
SOURCES += OtherDlg.cpp WholeApp.cpp

Of course, the Qt-Project file above is very simplistic, but shows how I included the stand-alone dialog box.

share|improve this answer
add comment

For Qt on Windows you can create DLLs for every subproject you want. No problem with using them from the main project (exe) after that. You'll have to take care of dependencies but it's not very difficult.

share|improve this answer
add comment

Yes, you can edit your main project (.pro) file to include your sub project's project file.

See here

share|improve this answer
add comment

Your Answer


