There was no need to change mainwindow.cpp, only the PRI file, and then you must rerun qmake.
//>>>>> 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[])
{
MainWindow w;
w.show();
return a.exec();
}
//>>>>> gui/gui.pri
INCLUDEPATH += gui
DEPENDPATH += gui
SOURCES += gui/mainwindow.cpp
HEADERS += gui/mainwindow.h
//>>>>> gui/mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
{
Q_OBJECT
public:
~MainWindow();
};
#endif // MAINWINDOW_H
//>>>>> gui/mainwindow.cpp
#include "mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
){
}
MainWindow::~MainWindow()
{
}
//>>>>> 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();
}
//>>>>> gui/gui.pri
INCLUDEPATH += gui
DEPENDPATH += gui
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()
{
}
To copy to clipboard, switch view to plain text mode
Works fine, even if you remove the "gui/" from the #include in main.cpp.
Bookmarks