[Qt-interest] Qt C++ with some C++.NET calls

Gino VH ginovh2002 at yahoo.com
Sat Jan 16 09:00:56 CET 2010


Hello,

with some small changes to the generated vcproj file I could compile this "hello world" .NET program with Qt.
I am not sure this flow will work for you. But you can give it a try.

#include <QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
 System::Console::WriteLine("Hello, World!");
    QApplication app(argc, argv);
    QLabel *label = new QLabel("Hello Qt!");
    label->show();
    return app.exec();
}

What I did:
1) Build Qt for VS2008 (I guess you already have build, but it is important you build as dynamic lib, which is the default):
configure.exe -debug-and-release -platform win32-msvc2008
nmake sub-src
nmake sub-tools
2) make Qt project like you always would do for Qt 
qmake -project
qmake -tp vc hello.pro
3) Modify the project settings in VS IDE for CLR code:
Project properties >> Configuration Properties >> General >> Common language runtime support >> Common language runtime support /clr
Project properties >> Configuration Properties >> C/C++ >> Code Generation >> Enable C++ exceptions >> No

Make sure if you want to see console output that you have this line in your .pro file :
CONFIG += console

this worked in my case.

good luck,

Gino


      




More information about the Qt-interest-old mailing list