I was wondering how to use a QT Project into another in QTCreator. I've created a subdirs test 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 class "firstclass" (ConsoleSubProject) in GuiSubProject. To do so, I've added this line in GuiSubProject.pro :
include(../ConsoleSubProject/ConsoleSubProject.pro)
When I've tried to build the project, it give me errors :
MainProject/GuiSubProject/mainwindow.hpp:4: error: QMainWindow: No such file or directory
If you have any idea about how can I use the class of project into another ?
Regards
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
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With