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
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = feather
TEMPLATE = app
include(gui/gui.pri)
SOURCES += main.cpp
To copy to clipboard, switch view to plain text mode
main.cpp
#include <QApplication>
#include "gui/mainwindow.h"
int main(int argc, char *argv[])
{
MainWindow w;
w.show();
return a.exec();
}
#include <QApplication>
#include "gui/mainwindow.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
To copy to clipboard, switch view to plain text mode
gui/gui.pri
SOURCES += gui/mainwindow.cpp
HEADERS += gui/mainwindow.h
SOURCES += gui/mainwindow.cpp
HEADERS += gui/mainwindow.h
To copy to clipboard, switch view to plain text mode
gui/mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
{
Q_OBJECT
public:
~MainWindow();
};
#endif // 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
To copy to clipboard, switch view to plain text mode
gui/mainwindow.cpp
#include "mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
){
}
MainWindow::~MainWindow()
{
}
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
}
MainWindow::~MainWindow()
{
}
To copy to clipboard, switch view to plain text mode
This is about as barebones as it gets. The error received is:
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_VERSION, 4): QT += widgets
TARGET = feather
TEMPLATE = app
SOURCES += main.cpp \
gui/mainwindow.cpp
HEADERS += gui/mainwindow.h
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = feather
TEMPLATE = app
SOURCES += main.cpp \
gui/mainwindow.cpp
HEADERS += gui/mainwindow.h
To copy to clipboard, switch view to plain text mode
I don't know why it's dependent on feather/mainwindow.h instead of feather/gui/mainwindow.h. Any advice?
Bookmarks