QTCreator: use qt project in another

I was wondering how to use the QT Project in another in QTCreator. I created a subdirs testing project with this hierarchy:

MainProject MainProject.pro ConsoleSubProject ConsoleSubProject.pro main.cpp firstclass.hpp firstclass.cpp GuiSubProject GuiSubProject.pro main.cpp mainwindow.hpp mainwindow.cpp 

I would like to use the "firstclass" class (ConsoleSubProject) in GuiSubProject. For this, I added this line to GuiSubProject.pro:

 include(../ConsoleSubProject/ConsoleSubProject.pro) 

When I tried to build the project, it gave me errors:

 MainProject/GuiSubProject/mainwindow.hpp:4: error: QMainWindow: No such file or directory 

If you have an idea on how I can use the project class in another?

Hi

+6
source share
2 answers

You can do something like this:

MainProject / common.pri

  INCLUDEPATH += $$PWD/ConsoleSubProject SOURCES += $$PWD/ConsoleSubProject/firstclass.cpp HEADERS += $$PWD/ConsoleSubProject/firstclass.hpp 

MainProject / ConsoleSubProject / ConsoleSubProject.pro

  include(../common.pri) QT += core SOURCES += main.cpp 

MainProject / GuiSubProject / GuiSubProject.pro

  include(../common.pri) QT += core gui SOURCES += main.cpp mainwindow.cpp HEADERS += mainwindow.hpp 
+5
source

Instead of include (.. / .....) in your GuiSubProject.pro it should be

  INCLUDEPATH = ../ConsoleSubProject 
0
source

All Articles