PDA

View Full Version : Several problems on starting with QT (Creator)



rockzOr
16th August 2010, 11:35
Hi,

first of all I hope you can help me solving my problems or my short look at QT will be over very soon.
In the past I've written my programs in Delphi. Now I want to have a look in C++ and the best and easiest way which I've found was QT, cause it's free ;)

After Installation I started the Creator, just to create a new blank project and tried to start it. But there the problems begin. If I create a new project, there are 2 problems:

1.) If I save the project on another disc (Installed on C: - Project saved on D:), the Makefile gets 'corrupted', so there isn't any drive letter like c:/programs/... etc., there is everything which leads to my installation path like

Volume{Volume-ID}/path/to/qt

So the compiler can't find anything he needs. If I change the paths by hand, it just resolves to my second problem.

2.) For the second problem, I solved the issue above with just creating the project on the same disc device. There is no problem with the Makefile, but the compile didn't complete also, because of error message during the whole source. Just to remember: I've changed nothing, just created a new project.

The first error is one that belongs to non existant file "ui_mainwindow.h". If I create it, the following errors are the same, I only get fixed this one (even if it's empty).



Running build steps for project untitled1...

Starting: "c:/programme/qt/qt/bin/qmake.exe" C:/Programme/QT/qt/untitled1/untitled1.pro -r -spec win32-g++

debug_and_release.prf:1: Unknown test function: addExclusiveBuilds

The process "c:/programme/qt/qt/bin/qmake.exe" exited normally.

Starting: "C:/Programme/QT/mingw/bin/mingw32-make.exe" -w

mingw32-make: Entering directory `C:/Programme/QT/qt/untitled1-build-desktop'

g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\include\QtCore" -I"..\include\QtGui" -I"..\include" -I"..\include\ActiveQt" -I"tmp\moc\debug_shared" -I"c:\Programme\QT\qt\untitled1-build-desktop" -I"c:\Programme\QT\qt\mkspecs\win32-g++" -o tmp\obj\debug_shared\main.o ..\untitled1\main.cpp

g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\include\QtCore" -I"..\include\QtGui" -I"..\include" -I"..\include\ActiveQt" -I"tmp\moc\debug_shared" -I"c:\Programme\QT\qt\untitled1-build-desktop" -I"c:\Programme\QT\qt\mkspecs\win32-g++" -o tmp\obj\debug_shared\mainwindow.o ..\untitled1\mainwindow.cpp

..\untitled1\mainwindow.cpp:2:27: error: ui_mainwindow.h: No such file or directory

..\untitled1\mainwindow.cpp: In constructor 'MainWindow::MainWindow(QWidget*)':

..\untitled1\mainwindow.cpp:6: error: invalid use of incomplete type 'struct Ui::MainWindow'

..\untitled1\/mainwindow.h:7: error: forward declaration of 'struct Ui::MainWindow'

..\untitled1\mainwindow.cpp:8: error: invalid use of incomplete type 'struct Ui::MainWindow'

..\untitled1\/mainwindow.h:7: error: forward declaration of 'struct Ui::MainWindow'

..\untitled1\mainwindow.cpp: In destructor 'virtual MainWindow::~MainWindow()':

..\untitled1\mainwindow.cpp:13: warning: possible problem detected in invocation of delete operator:

..\untitled1\mainwindow.cpp:13: warning: invalid use of incomplete type 'struct Ui::MainWindow'

..\untitled1\/mainwindow.h:7: warning: forward declaration of 'struct Ui::MainWindow'

..\untitled1\mainwindow.cpp:13: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.

mingw32-make: Leaving directory `C:/Programme/QT/qt/untitled1-build-desktop'

mingw32-make: *** [tmp/obj/debug_shared/mainwindow.o] Error 1

The process "C:/Programme/QT/mingw/bin/mingw32-make.exe" exited with code %2.

Error while building project untitled1 (target: Desktop)

When executing build step 'Make'


I'm quite new to C++ so I can't 'fix' this easy, just in fact, that I didn't changed anything and I just thought that a blank new project will start without any problems... I guess there is something wrong with my Installation, but I can't find a reason to prove this.

Just to let you know about my environment:

I've installed a Virtual Machine using VMWare. The OS is Windows XP Professional Service Pack 3 with all the latest Updates. I have 3 Virtual Discs, Disc 1 is C:, Disc 2 is D: and Disc 3 is a NTFS Folder at C:\Programme in which I have installed QT.

I hope anyone could give me a hint how I can solve this issues, just to have a clean start and try to learn some basics and maybe write my first apps ;) If there are any open questions, just ask.

alexisdm
16th August 2010, 12:39
Can you show the content of the file untitled1.pro ?

rockzOr
16th August 2010, 12:46
Sure, here it is (as I said, it's default):



#-------------------------------------------------
#
# Project created by QtCreator 2010-08-16T11:29:08
#
#-------------------------------------------------

QT += core gui

TARGET = untitled1
TEMPLATE = app


SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

FORMS += mainwindow.ui

lyuts
16th August 2010, 14:12
Via Build menu in Qt Creator try cleaning the project, running qmake and building the project again. Looks like you somehow messed your paths.

rockzOr
16th August 2010, 14:40
Hi,

I tried your answer, but it doesn't change anything. Cleaning and qmake working fine, but if I try to start the app, it just fails with the errors above.

I hope this can be fixed anyway, I thought it would just work out-of-the-box if I create a new project... I tried out the examples now, but it's the same there. I can't build any example, it stops with a huge amount of errors belonging to which example I choose. I installed it the usual way, I just edited the path to which QT should be installed, rest of the installation was default and should be as normal.

lyuts
16th August 2010, 16:44
Is there ui_mainwindow.h somewhere in your source directory?

rockzOr
16th August 2010, 16:50
... No there isn't. And I don't know why the Creator needs it, or includes it if it's not present. Just to clarify: This is the result of New Project->Default Settings->OK->Start. Nothing changed, nothing edited, nothing configured. Just out-of-the-box startup.

And as I said above, even if I create this file, the errors posted in my first post won't be solved by that.

lyuts
16th August 2010, 16:56
... No there isn't. And I don't know why the Creator needs it, or includes it if it's not present.

This file is a generated one. Qt Creator doesn't need this file, but your application does. Could you show the contents of the untitled1 directory?

rockzOr
17th August 2010, 09:08
There is no ui_mainwindow.h. And seriously, that's not the error I'm interested in. I can create this file on my own. The problems are still the same: Nothing works, not a clean, new project, not an example, nothing. If this file is generated, it's missing everywhere. If my application needs it (so *every* application which is newly created will need it - only with adjusted name), this is a bug. But even if this won't be, the error I quoted in my first post are still there.

Again to clarify: My problem is, that even if I create a new, blank project, don't change anything after a fresh Installation of QT SDK package, nothing works, even the examples. If I create a new project and just want to start it after it's created to check if it works out-of-the-box and ignore this ui_mainwindow.h error, I still have these:



..\untitled1\mainwindow.cpp: In constructor 'MainWindow::MainWindow(QWidget*)':
..\untitled1\mainwindow.cpp:6: error: invalid use of incomplete type 'struct Ui::MainWindow'
..\untitled1\/mainwindow.h:7: error: forward declaration of 'struct Ui::MainWindow'
..\untitled1\mainwindow.cpp:8: error: invalid use of incomplete type 'struct Ui::MainWindow'
..\untitled1\/mainwindow.h:7: error: forward declaration of 'struct Ui::MainWindow'
..\untitled1\mainwindow.cpp: In destructor 'virtual MainWindow::~MainWindow()':
..\untitled1\mainwindow.cpp:13: warning: possible problem detected in invocation of delete operator:
..\untitled1\mainwindow.cpp:13: warning: invalid use of incomplete type 'struct Ui::MainWindow'
..\untitled1\/mainwindow.h:7: warning: forward declaration of 'struct Ui::MainWindow'
..\untitled1\mainwindow.cpp:13: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.

SixDegrees
17th August 2010, 09:44
UI files are machine-generated files produced by Qt's MOC. Chances are high that if you're missing them, there's something wrong in your code. The first things to check for would be that you have derived (directly or indirectly) from QObject, and that you have included the QOBJECT macro in your class declaration.

If that doesn't clear things up, post your source code.

rockzOr
17th August 2010, 10:16
Really, I begin to start thinking that no one reads my posts... I don't have an own source code! I just create a NEW project and don't change anything. A complete NEW project with File->New project, nothing else. Even the examples, where the source code should be OK, because they are examples, doesn't work. The source code is default, standard created and yes, there is an QOBJECT inside the class declaration, it's the first line after class <Name> {...}.

If there is anything unclear, I could provide screenshots, full code quote of the default created (...) and anything else, but please don't answer standard things which can't belong to my problem. If you don't know, say it and I give up.

tbscope
17th August 2010, 10:35
Did you install the Qt SDK ?
Can the moc program be found?

rockzOr
17th August 2010, 10:52
Yes, I installed the complete SDK including the Creator from nokia.com.
How can I check if moc can be found?

tbscope
17th August 2010, 11:27
Does the qt installation directory contain moc (in the bin directory) ?

Go to the console, but not in the qt installation dir, and type in moc. Does it get found?
If not, your PATH environment variable needs to be set to your qt install dir/bin

rockzOr
17th August 2010, 13:17
There is a moc.exe in the bin directory of QT, yes.

If I type moc.exe in the console, it can't be found. So I edited my path to extend it with the QT install dir/bin.

But if I want to start it than, I get this error:



Could not find make command: mingw32-make.exe in the build environment

Error while building project untitled (target: Desktop)

When executing build step 'Make'


So I edited my PATH variable again to give it the path to mingw-make.exe.
And after that, the same error occurs:



Running build steps for project untitled...

Configuration unchanged, skipping qmake step.

Starting: "C:/Programme/QT/mingw/bin/mingw32-make.exe" -w

mingw32-make: Entering directory `C:/Programme/QT/qt/untitled-build-desktop'

g++ -c -g -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_THREAD_SUPPORT -DQT_NEEDS_QMAIN -I"..\include\QtCore" -I"..\include\QtGui" -I"..\include" -I"..\include\ActiveQt" -I"tmp\moc\debug_shared" -I"c:\Programme\QT\qt\untitled-build-desktop" -I"c:\Programme\QT\qt\mkspecs\win32-g++" -o tmp\obj\debug_shared\mainwindow.o ..\untitled\mainwindow.cpp

..\untitled\mainwindow.cpp:2:27: error: ui_mainwindow.h: No such file or directory

..\untitled\mainwindow.cpp: In constructor 'MainWindow::MainWindow(QWidget*)':

..\untitled\mainwindow.cpp:6: error: invalid use of incomplete type 'struct Ui::MainWindow'

..\untitled\/mainwindow.h:7: error: forward declaration of 'struct Ui::MainWindow'

..\untitled\mainwindow.cpp:8: error: invalid use of incomplete type 'struct Ui::MainWindow'

..\untitled\/mainwindow.h:7: error: forward declaration of 'struct Ui::MainWindow'

..\untitled\mainwindow.cpp: In destructor 'virtual MainWindow::~MainWindow()':

..\untitled\mainwindow.cpp:13: warning: possible problem detected in invocation of delete operator:

..\untitled\mainwindow.cpp:13: warning: invalid use of incomplete type 'struct Ui::MainWindow'

..\untitled\/mainwindow.h:7: warning: forward declaration of 'struct Ui::MainWindow'

..\untitled\mainwindow.cpp:13: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.

mingw32-make: Leaving directory `C:/Programme/QT/qt/untitled-build-desktop'

mingw32-make: *** [tmp/obj/debug_shared/mainwindow.o] Error 1

The process "C:/Programme/QT/mingw/bin/mingw32-make.exe" exited with code %2.

Error while building project untitled (target: Desktop)

When executing build step 'Make'