How to create Qt apps (VS2008) ?
-
Hi everyone, nice weekend! I am newcomer with Qt, I follow "tutorial":http://msdnvietnam.net/blogs/risman/archive/2009/04/02/qt-4-5-with-visual-studio-2008-vc-express.aspx to set up developing environment for Qt, However, at the end of guide, author wasn't described how to create Qt4 projects in Visual Studio 2008, I try to create Win32 project to store Qt coding but compiling fail:
@
#include <QApplication>
#include <QLabel>int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("Hello Qt");
label->show();
return app.exec();
}
@!http://nm0.upanh.com/b5.s26.d1/012e9d0e1e410b9893d4af9e21c2547b_44641190.h1.png(Error)!
Any idea, thanks!
-
You have received and error that QApplication cannot be find. Have you configured Qt include path and dependencies for linking?
-
Yup, go to your projects properties and add this to C/C++ > General > Additional Include Directories:
$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;I would suggest to set up an environment variable QTDIR, which points to the Qt install root directory, on your system. Otherwise, you have to replace the "$(QTDIR)" parts with the path to your Qt install directory. Also note that you have to restart VisualStudio after setting up an new environment variable...
-
Have you installed the "Visual Studio Add-In for Qt":http://qt.nokia.com/downloads/visual-studio-add-in? Careful though, it doesn't work for Visual Studio Express Version. After you install it, inside Visual Studio go to Qt->Qt Options and select the Qt SDK installed that you are about to use and you should be ready to successfully compile any Qt project.
Generally you can either create a new Qt project from the File-> New-> Project-> Qt4 Projects-> Qt Console Application. Or import an already existing Qt project by Qt-> Open Qt Project File (.pro).
Edit: just saw that the link that you posted has instruction on how to build the Qt. You don't have to do that. Go download directly the Qt SDK setup file from http://qt.nokia.com/downloads/windows-cpp-vs2008.