Subfolder Organization



  • I've reviewed several similar questions and their answers and nothing I've tried thus far has worked.

    I'm starting a Qt project that will be quite large in scope. To keep things better organized, I intend on utilizing subdirectories within my Qt project. Things are not off to a good start.

    I am using: Qt Creator 2.8.1 based on Qt 5.1.1

    Here is what I've come up with based on previous answers I've seen:

    feather.pro:

    @QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    TARGET = feather
    TEMPLATE = app

    include(gui/gui.pri)

    SOURCES += main.cpp@

    main.cpp:

    @#include <QApplication>
    #include "gui/mainwindow.h"

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec&#40;&#41;;
    

    }@

    gui/gui.pri:

    @SOURCES += gui/mainwindow.cpp
    HEADERS += gui/mainwindow.h@

    gui/mainwindow.h

    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    MainWindow(QWidget *parent = 0);
    ~MainWindow();
    };

    #endif // MAINWINDOW_H@

    gui/mainwindow.cpp

    @#include "mainwindow.h"

    MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    {
    }

    MainWindow::~MainWindow()
    {
    }@

    This is about as barebones as it gets. The error received is:

    bq. Error: dependent '..\feather\mainwindow.h' does not exist. jom:
    C:\Users\Zac\Dev\Qt\build-feather-Desktop_Qt_5_1_1_MSVC2012_32bit-Debug\Makefile
    [debug] Error 2 16:12:50: The process
    "C:\Qt\Qt5.1.1\Tools\QtCreator\bin\jom.exe" exited with code 2. Error
    while building/deploying project feather (kit: Desktop Qt 5.1.1
    MSVC2012 32bit) When executing step 'Make'

    The error is the same if I use the standard feather.pro:

    @QT += core gui

    greaterThan(QT_MAJOR_VERSIN, 4): QT += widgets

    TARGET = feather
    TEMPLATE = app

    SOURCES += main.cpp
    gui/mainwindow.cpp
    HEADERS += gui/mainwindow.h@

    I don't know why it's dependent on feather/mainwindow.h instead of feather/gui/mainwindow.h. Any advice?



  • Hi,

    you should add this line in .pro file

    @
    INCLUDEPATH += gui
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.