Compiling a simple Qt “Hello World!” application within Visual Studio 2010 Express?

后端 未结 5 1269
予麋鹿
予麋鹿 2021-01-06 02:35

I\'m trying to build a basic Qt \"Hello, world!\" application inside Visual Studio.

I got the moc step to work (I think), but now I am at a loss as to h

5条回答
  •  余生分开走
    2021-01-06 03:08

    qmake will generate the moc voodoo from the header file in .pro file. As you aren't using qmake, by the sound of it, but a native visual studio project, this is probably the cause of the problem.

    If you use qmake to generate your visual studio project all your problems will go away and life will be sweet. Probably!

    I am using the open 2010.05; obviously you want to substitute the correct path for your version.

    set up the environment

    start 2010 command environment from the start menu
    -set include=%include%;C:\Qt\2010.05\qt\include
    -set lib=%lib%;C:\Qt\2010.05\qt\lib -set path=%path%;C:\Qt\2010.05\qt\bin
    -set QMAKESPEC=win32-msvc2010

    write code, create files etc

    generate the initial pro and makefile and fire up VS
    -qmake -tp vc
    -qmake

    you should now have a makefile - check that it works by running:
    -nmake

    now launch visual studio
    -VCExpress.exe /useenv
    -XXX.vcxproj can now be opened

    If this doesn't work you may need to build qt at against visual studio. This is very straightforward - go to the qt directory (from within the visual studio express command window) and type:

    configure.exe -platform win32-msvc2010 -no-webkit -no-phonon -no-phonon-backend -no-script -no-scripttools -no-multimedia -no-qt3support -fast
    

提交回复
热议问题