Please Help me How to install QT on VC++ 2008
-
"Here":/doc/gettingstarted.html is a good starting point.
-
my question exactly is "how to include qt headers and library to vs 2008"? if i install "qt-win-opensource-4.7.4-vs2008" and "Qt Visual Studio Add-in", its enough ?!! or i must compile or copy or set inlcude directory to vs ? sorry for my bad eng language
-
You need to set Qt installation directory. You should have Qt menu on VC menubar. Open it and choose Options and set Qt installation directory. Other solutions is to set QTDIR environment variable.
-
c:\qt\4.7.4
-
... and you still are unable to build projects with Qt dependency ?
If not, what are the errors ? -
yes exactly . 1) i install qt-win 2) install qt vs add in 3) create qt application with qt addin 4)push F7(build solution)
Errors:
Warning 2 warning C4273: 'staticQtMetaObject' : inconsistent dll linkage c:\Users\AhUrA\Documents\Visual Studio 2008\Projects\Qt\Qt\GeneratedFiles\Debug\moc_qt.cpp 41
Error 7 fatal error C1903: unable to recover from previous error(s); stopping compilation c:\Users\AhUrA\Documents\Visual Studio 2008\Projects\Qt\Qt\qt.cpp 4
Error 6 error C4430: missing type specifier - int assumed. Note: C++ does not support default-int c:\Users\AhUrA\Documents\Visual Studio 2008\Projects\Qt\Qt\qt.cpp 4
Error 9 error C2882: 'Qt' : illegal use of namespace identifier in expression c:\Users\AhUrA\Documents\Visual Studio 2008\Projects\Qt\Qt\main.cpp 7
Error 1 error C2869: 'Qt' : has already been defined to be a namespace c:\users\ahura\documents\visual studio 2008\projects\qt\qt\qt.h 7
Error 4 error C2869: 'Qt' : has already been defined to be a namespace c:\users\ahura\documents\visual studio 2008\projects\qt\qt\qt.h 7
Error 8 error C2869: 'Qt' : has already been defined to be a namespace c:\users\ahura\documents\visual studio 2008\projects\qt\qt\qt.h 7
Error 3 error C2491: 'QObject::staticQtMetaObject' : definition of dllimport static data member not allowed c:\Users\AhUrA\Documents\Visual Studio 2008\Projects\Qt\Qt\GeneratedFiles\Debug\moc_qt.cpp 41
Error 13 error C2228: left of '.show' must have class/struct/union c:\Users\AhUrA\Documents\Visual Studio 2008\Projects\Qt\Qt\main.cpp 8
Error 10 error C2146: syntax error : missing ';' before identifier 'w' c:\Users\AhUrA\Documents\Visual Studio 2008\Projects\Qt\Qt\main.cpp 7
Error 11 error C2065: 'w' : undeclared identifier c:\Users\AhUrA\Documents\Visual Studio 2008\Projects\Qt\Qt\main.cpp 7
Error 12 error C2065: 'w' : undeclared identifier c:\Users\AhUrA\Documents\Visual Studio 2008\Projects\Qt\Qt\main.cpp 8
Error 5 error C2039: 'Qt' : is not a member of 'Qt' c:\Users\AhUrA\Documents\Visual Studio 2008\Projects\Qt\Qt\qt.cpp 3 -
Try to rename your files. From what I see you have Qt.cpp and Qt.h in your project. And don't use only Qt in your namespaces or class definitions or other defined type.
-
So, it's not a include Qt headers error, this means VC recognize your Qt installation. I suspect something wrong in your code. Can you post the code ?
-
@
#ifndef QT_H
#define QT_H#include <QtGui/QMainWindow>
#include "ui_qt.h"class Qt : public QMainWindow
{
Q_OBJECTpublic:
Qt(QWidget *parent = 0, Qt::WFlags flags = 0);
~Qt();private:
Ui::QtClass ui;
};#endif // QT_H
@@#include "qt.h"
Qt::Qt(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);
}Qt::~Qt()
{}
@@#include "qt.h"
#include <QtGui/QApplication>int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Qt w;
w.show();
return a.exec();
}
@ -
First, please be more patiently. We all do the support here in our spare time and as volunteers. If your topic has that much answers, someone will surely come back with an answer.
As others already have mentioned, do not name your class Qt! This will conflict with the Qt namespace in the Qt libs itself. Additionally, it's good practice to not prefix your own classes with Q or Qt, as this is informally reserved for Qt's own classes.
-
Yes, this works.
You can use the prebuilt binaries for VS2008 - there's no need to build them yourself.