PDA

View Full Version : Core headers not found



CDRW
5th August 2011, 06:24
Hi,

I'm trying to learn the Qt framework as best as I can, and I thought the best course of action for this was to work through the tutorials, one at a time. I originally used the add-in for VS2010 on my first try to compile cpp files meant for Qt. The problem I am always having is that it reports QApplication and QPushbutton, as in the first two includes in the first "Hello world" application on the tutorial, as missing. I searched and found them located in QtGUI. I tried to use them and it resulted in it reporting that the functions were not valid, even going as far as to move the header files into the project directory, nothing. I rebuilt the Qt binaries and made sure all of my build targets were correct, before giving up and getting Qt SDK.

Now I'm having the same problem in Qt SDK. Build target appears to be correct, it works just fine for Qt Quick applications, but it does not appear to be able to build any files or example projects that I download. Searching for a similar problem is just making me run in circles doing the same things over and over again.

Here is the code

#include <QCoreApplication>
#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
QApplication app(argc, argv);

QPushButton hello("Hello world!");
hello.resize(100, 30);

hello.show();
return app.exec();
}


Putting this into Qt SDK results in it claiming that it can't find QApplication or QtPushButton.

Changing this to



#include <QtGUI\QApplication>
#include <QtGUI\QPushButton>

Removes the problem, but now it claims that the function is invalid, or at least that's what I think it is saying.


D:\Qt\test\main.cpp:-1: error: undefined reference to `_imp___ZN12QApplicationC1ERiPPcbi'
D:\Qt\test\main.cpp:-1: error: undefined reference to `_imp___ZN11QPushButtonC1ERK7QStringP7QWidget'

It's likely something very small and very stupid (probably some stupid step I skipped). Any ideas are welcome, assume that I have no idea what I am doing.

NullPointer
5th August 2011, 06:45
You don't need to use "QtGui\"...

Just review your .pro file, and make sure you have a line like:


QT += core gui


And you should not have a "QT -= core"...

HTH

CDRW
5th August 2011, 09:05
Still isn't working

That's the first line inside of it.


EDIT: Update: I've found that it actually works just fine in Code::Blocks. I am not entirely sure why.