Pages

Hello Qt

To use Qt with VC++ 2010 you should set a few prerequisite.

In Project Properties - Configuration Properties

add C:\Qt\4.6.2\lib; (or your actual Qt lib directory) to Linker - General - Additional Library Directories
add QtCore4.lib;QtGui4.lib to Linker - Input - Additional Dependencies
add C:\Qt\4.6.2\include; (or your actual Qt include directory) to C/C++ - General - Additional Include Directories

Done that, it is quite easy to develop an hello Qt program:

#include <QtGui/QApplication>
#include <QtGui/QLabel>

int main(int argc, char** argv)
{
QApplication app(argc, argv);
QLabel label("Hello Qt!");
label.show();

return app.exec();
}

As any hello program, it is not doing much, just showing in a minimal window a greeting text. But we have created a real window that could be moved, resized, and even closed.

No comments:

Post a Comment