Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QTCreator : Use qt project into another

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

like image 937
Aleanar Avatar asked Jan 30 '13 14:01

Aleanar


1 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
like image 101
Kirween Avatar answered Sep 28 '22 00:09

Kirween