PDA

View Full Version : Cannot use a existing Designer UI File in my application



Guett_31
14th February 2013, 06:48
I'm running Qt5.0.0 msvc2010 and I'm trying to add 3 files to a very basic project using the "add existing files" option of Qt Creator. The only intent of this project is to display a window created with Qt Designer.
The 3 files are mainwindow.h, mainwindow.cpp and mainwindow.ui automatically generated by Qt Designer.
When I try to compile, I get this: fatal error C1083: Cannot open include file: 'mainwindow.h': No such file or directory.

The files are correctly located in my projet file and qmake runs fine.

QT += widgets
SOURCES += \
main.cpp \
../test/mainwindow_test_form/mainwindow.cpp8718

FORMS += \
../test/mainwindow_test_form/mainwindow.ui

HEADERS += \
../test/mainwindow_test_form/mainwindow.h
My main.cpp files look like this:

#include <QApplication>
#include <QtGui>
#include "mainwindow.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MainWindow theMainWindow;
theMainWindow.show();
return app.exec();
}

I tried to put the 3 files in different locations (in or out of the project) and I still get the same result.
Any Suggestions?

Thanks!


I have attached a screenshot of my project in Qt Creator too. It might help.

alrawab
14th February 2013, 07:43
#include "mainwindow.h" ==> #include "../test/mainwindow_test_form/mainwindow.h"

Lykurg
14th February 2013, 08:06
Or you can simply add INCLUDEPATH += ../test/mainwindow_test_form to the pro file.

Guett_31
14th February 2013, 19:41
Thank to both of you! I tried both approachs and they work.
I prefer Lykurg'a approach though. If the files change location later, I'll just have to update the path in one place.