hechengjin 发表于 2016-7-8 10:58:59

如何把VC工程.vcproj转化为Qt工程.pro

本帖最后由 hechengjin 于 2016-7-27 10:06 编辑

http://blog.csdn.net/willib/article/details/50965717
我的环境配置是VS2008+Qt5,装的QT插件是qt-vs-addin-1.2.4-opensource,按道理说在装好插件后就可以创建.pro工程的,但是当打开一个vc工程后QT插件下面却是灰色的不可用状态,如下图所示:http://img.blog.csdn.net/20160323190152927?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
谷歌了一下,搜到一个解决方案:http://stackoverflow.com/questio ... ect-to-a-qt-project
Using Visual Studio 2010+ it is now possible to convert a project to a Qt Addin project, using the "Convert project to Qt Add-in project" feature of the Qt Addin.The following steps are from the work around in bug QTVSADDINBUG-27. This was tested with Visual Studio 2010, but should work similarly with new versions:
[*]Right click on your project in "Solution Explorer", click on "Unload Project"
[*]Right click on your project in "Solution Explorer", click on "Edit .vcxproj"
[*]Add line <Keyword>Qt4VSv1.0</Keyword> between the tags <PropertyGroup Label="Globals">and </PropertyGroup>.
[*]Right click on your project in "Solution Explorer", click on "Reload Project"
[*]Right click on your project in "Solution Explorer", click on "Convert project to Qt Add-in project"
If you have header files in your project you are going to have to follow the instructions in this answerto trigger the generation of moc_* files in the "Generated Files" folder.For editions of Visual Studio older than 2010 see this work around.但是按照上面的说法并没有那个PropertyGroup标签,后来灵机一动,虽然插件不能导出.pro工程,但是却可以打开一个.pro工程,所以打开了一个QT工程,就在vs上自动产生了vc工程,然后按照上面的办法,编辑.vcproj文件,对比后应该在原来的VC工程中修改和加入以下信息,在上面的第三步处。http://img.blog.csdn.net/20160323214920085?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
注意上图中keyword=“Qt4VSv1.0”是需要修改的地方,还有下图的globals标签:http://img.blog.csdn.net/20160323215220636?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
这样添加完后再reload project ,这样在看Qt插件中的选项就变为可选了,http://img.blog.csdn.net/20160323215422995?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
接下来就可以继续往下操作了。
应老大要求写了一个文档:http://download.csdn.net/detail/enter_/9485356
页: [1]
查看完整版本: 如何把VC工程.vcproj转化为Qt工程.pro