在没有加载项的情况下将Qt与Visual Studio一起使用 [英] Using Qt with Visual Studio without add-in

查看:124
本文介绍了在没有加载项的情况下将Qt与Visual Studio一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用Qt库,但遇到了一个问题。
是否可以在没有特殊加载项的情况下将Qt与Visual Studio一起使用?

I recently started using Qt library and I've got a question. Is this possible to use Qt with Visual Studio without special add-in?

我只想使用qt设计器设计UI,然后在VS中完成其余工作表现。
我该怎么做?

I want to just design the UI using qt designer and do the rest in VS Express. How do I do that?

谢谢。

推荐答案

是的,如果您不想使用 QtVSAddin ,则非常容易在没有VS加载项和的情况下,将Qt与VS Express结合使用,而无需手动执行uic或moc 的任何步骤。让QMake(与Qt一起安装但不是QtVSAddin的一部分)创建VS项目文件,并在qmake项目文件中进行所有项目设置。每当您进行更改(例如添加/删除表单或源)时,请修改qmake项目文件并重新生成VS项目。完全不要修改VS项目文件,仅将其视为临时项。 QMake会将规则自动添加到VS项目文件中,以重新运行 uic moc ,如果您只是修改源代码或表单,则无需执行任何操作。

Yes you can, if you would prefer not to use the QtVSAddin it is very easy to use Qt with VS Express without the VS add-in and without having to do any of the uic or moc steps manually. Let QMake (installed with Qt but not part of the QtVSAddin) create your VS project file and do all your project setup in a qmake project file. Whenever you make a change like adding/removing a form or source, modify the qmake project file and regenerate the VS project. Don't modify the VS project file at all, treat it only as a temporary item. QMake will add the rules automatically to the VS project file to rerun uic and moc, you don't need to do anything if you're just modifying source code or forms.

出于配置管理的目的,我发现使用VS项目文件只是一个临时项目,这是使用此工作流的一种更干净的方法(它们往往差异很大,并且痛苦以维持版本控制)。

For configuration management purposes I find this a much cleaner approach to use this workflow as you treat the VS project file as only a temporary item (they tend to diff badly and are a pain to maintain in version control).

几个片段可以帮助您:

在您的qmake项目文件中,请确保添加在其中运行以下行,以便在Windows上运行时生成VS项目文件(qmake默认生成生成文件)。

In your qmake project file ensure you add the following line into it so that VS project files are generated when running on Windows (qmake defaults to generating a makefile).

your_qmake_proj.pro

win32: TEMPLATE = vcapp

另外,方便批处理文件来重新运行qmake,因此您不必调出命令提示符并设置环境(或在已经具有环境设置的命令提示符中将目录更改为项目)。如果尚未在Windows中设置各种Qt环境变量(或不想设置它们),请确保将它们添加到批处理文件中。

Additionally, it's convenient to have a batch file to rerun qmake so you don't have to bring up a command prompt and set environment up (or change directory to your project in a command prompt that already has the environment setup). If you haven't set the various Qt environment variables with Windows (or prefer not to) make sure to add them to your batch file.

makevcproj.bat

set QTDIR=C:\Qt\x.y.z
set PATH=%PATH%;%QTDIR%\bin
set QMAKESPEC=win32-msvcXXXX
qmake your_qmake_proj.pro
pause

这篇关于在没有加载项的情况下将Qt与Visual Studio一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆