如何在Visual Studio 2010中设置Qt路径?

时间:2022-09-01 15:54:02

I just downloaded and installed the latest versions of the Qt SDK, Qt Creator, and the Qt add-in for Visual Studio (I'm running VS 2010).

我刚下载并安装了最新版本的Qt SDK,Qt Creator和Visual Studio的Qt插件(我正在运行VS 2010)。

First, I tried creating a Qt project in VS2010. It came up with

首先,我尝试在VS2010中创建一个Qt项目。它提出来了

Unable to find a Qt build!

无法找到Qt版本!

To solve this problem specify a Qt build

要解决此问题,请指定Qt构建

So I go to the Qt -> Qt Options menu item in VS and click Add for the version.

所以我转到VS中的Qt - > Qt Options菜单项,然后单击Add for the version。

Now, I have 2 qmake.exe files: one in C:\Qt\2010.05\qt\qmake and one in C:\Qt\2010.05\qt\bin

现在,我有2个qmake.exe文件:一个在C:\ Qt \ 2010.05 \ qt \ qmake中,一个在C:\ Qt \ 2010.05 \ qt \ bin中

For some reason, if I select either one of these files, it comes up with the error message the this version of Qt was built with MingW. (I don't see why it makes a difference what compiled it, just so long as it's compiled?)

出于某种原因,如果我选择其中一个文件,它会出现错误消息,这个版本的Qt是用MingW构建的。 (我不明白为什么编译它会产生什么影响,只要它编译好了?)

After spending some time trying to find a working qmake.exe for the VS add-in I gave up and tried to get the original Qt creator to work instead.

花了一些时间试图为VS加载项找到一个有用的qmake.exe后,我放弃了,并尝试让原来的Qt创建者工作。

Qt creator is also not configured to run with itself (lol). When I select the path to either of my 2 qmake.exe files, it comes up with an error message when I try to compile a small program:

Qt创建者也没有配置为自己运行(lol)。当我选择2个qmake.exe文件中的任何一个的路径时,当我尝试编译一个小程序时会出现错误消息:

Could not find make command: make in the build environment

在构建环境中找不到make命令:make

Error while building project untitled (target: Desktop)

构建项目无标题时出错(目标:桌面)

When executing build step 'Make'

执行构建步骤'Make'时

When I check the options in Qt creator, it says qmake is at version 4.7.0 and that

当我检查Qt创建者中的选项时,它说qmake是4.7.0版本

Qt version is not properly installed, please run make install

Qt版本未正确安装,请运行make install

The VS2010 add-in is installed to my program files (x86) folder, but there are no qmake.exe files there.

VS2010加载项安装在我的程序文件(x86)文件夹中,但那里没有qmake.exe文件。

I'm running Windows 7 x64.

我正在运行Windows 7 x64。

4 个解决方案

#1


3  

Rebuild it with vs2010, it's much easier, and allows you to step into the Qt src in debug.

使用vs2010重建它,它更容易,并允许您在调试中进入Qt src。

In the top of the Qt src tree do
configure -no-webkit -no-qt3support -opensource -platform win32-msvc2010
(webkit is optional but it takes a long time to build)

在Qt src树的顶部配置-no-webkit -no-qt3support -opensource -platform win32-msvc2010(webkit是可选的,但构建需要很长时间)

Will build a .sln file which you can open in VS2010 and build

将构建一个.sln文件,您可以在VS2010中打开并构建

#2


4  

I'm almost positive that you have to rebuild the Qt libraries in Visual Studio first before you can use them. That probably explains why you're getting the error message that a Qt build can't be found, and that the version of Qt you're using was built with MinGW.

我几乎肯定你必须首先在Visual Studio中重建Qt库才能使用它们。这可能解释了为什么您收到无法找到Qt构建的错误消息,以及您使用的Qt版本是使用MinGW构建的。

I suggest reading this blog post for what looks to be a solid how-to guide on integrating Qt with VS.

我建议阅读这篇博文,了解将Qt与VS集成的实用指南。

This looks like an even simpler guide, although it's in PDF format: Qt Installation for Visual Studio

这看起来更简单,虽然它是PDF格式:Visual Studio的Qt安装

#3


2  

Firstly, it's quite normal that MinGW libraries don't work with Visual Studio. Read up on the subject if you're still angry.

首先,MinGW库不能与Visual Studio一起使用是很正常的。如果你还生气,请阅读这个主题。

The Qt SDK (if that's what you downloaded, should come with a pre-installed QtCreator that works with minimal or no setup with the included MinGW toolchain.

Qt SDK(如果你下载的话,应该附带一个预安装的QtCreator,它可以使用附带的MinGW工具链进行最少的设置或没有设置。

If you want to use Visual Studio with the add-in, you'll need to either try the Visual Studio 2008 download from this webpage or rebuild Qt yourself. It's not hard, just time-consuming. Pointing the add-in to the build or install location of either of those should get you going.

如果要将Visual Studio与加载项一起使用,则需要尝试从此网页下载Visual Studio 2008或自行重建Qt。这并不难,只是耗时。将加载项指向其中任何一个的构建或安装位置应该可以帮到您。

#4


0  

When you had older versions of Qt installed before, even if you uninstall them diligently, registry entry for Trolltech will still contain old values. To fix that, start Registry Editor (regedit.exe), scroll to:

当您之前安装了旧版本的Qt时,即使您勤勉地卸载它们,Trolltech的注册表项仍将包含旧值。要解决此问题,请启动注册表编辑器(regedit.exe),滚动到:

HKEY_CURRENT_USER\Software\Trolltech\Versions\DefaultQtVersion

HKEY_CURRENT_USER \ SOFTWARE \奇趣\版本\ DefaultQtVersion

and edit it to current version number. Check other entries in Trolltech group, to make sure they are set to current version. That solved the problem of

并将其编辑为当前版本号。检查Trolltech组中的其他条目,以确保它们设置为当前版本。这解决了问题

Unable to find a Qt build! To solve this problem specify a Qt build

无法找到Qt版本!要解决此问题,请指定Qt构建

for me.

为了我。

#1


3  

Rebuild it with vs2010, it's much easier, and allows you to step into the Qt src in debug.

使用vs2010重建它,它更容易,并允许您在调试中进入Qt src。

In the top of the Qt src tree do
configure -no-webkit -no-qt3support -opensource -platform win32-msvc2010
(webkit is optional but it takes a long time to build)

在Qt src树的顶部配置-no-webkit -no-qt3support -opensource -platform win32-msvc2010(webkit是可选的,但构建需要很长时间)

Will build a .sln file which you can open in VS2010 and build

将构建一个.sln文件,您可以在VS2010中打开并构建

#2


4  

I'm almost positive that you have to rebuild the Qt libraries in Visual Studio first before you can use them. That probably explains why you're getting the error message that a Qt build can't be found, and that the version of Qt you're using was built with MinGW.

我几乎肯定你必须首先在Visual Studio中重建Qt库才能使用它们。这可能解释了为什么您收到无法找到Qt构建的错误消息,以及您使用的Qt版本是使用MinGW构建的。

I suggest reading this blog post for what looks to be a solid how-to guide on integrating Qt with VS.

我建议阅读这篇博文,了解将Qt与VS集成的实用指南。

This looks like an even simpler guide, although it's in PDF format: Qt Installation for Visual Studio

这看起来更简单,虽然它是PDF格式:Visual Studio的Qt安装

#3


2  

Firstly, it's quite normal that MinGW libraries don't work with Visual Studio. Read up on the subject if you're still angry.

首先,MinGW库不能与Visual Studio一起使用是很正常的。如果你还生气,请阅读这个主题。

The Qt SDK (if that's what you downloaded, should come with a pre-installed QtCreator that works with minimal or no setup with the included MinGW toolchain.

Qt SDK(如果你下载的话,应该附带一个预安装的QtCreator,它可以使用附带的MinGW工具链进行最少的设置或没有设置。

If you want to use Visual Studio with the add-in, you'll need to either try the Visual Studio 2008 download from this webpage or rebuild Qt yourself. It's not hard, just time-consuming. Pointing the add-in to the build or install location of either of those should get you going.

如果要将Visual Studio与加载项一起使用,则需要尝试从此网页下载Visual Studio 2008或自行重建Qt。这并不难,只是耗时。将加载项指向其中任何一个的构建或安装位置应该可以帮到您。

#4


0  

When you had older versions of Qt installed before, even if you uninstall them diligently, registry entry for Trolltech will still contain old values. To fix that, start Registry Editor (regedit.exe), scroll to:

当您之前安装了旧版本的Qt时,即使您勤勉地卸载它们,Trolltech的注册表项仍将包含旧值。要解决此问题,请启动注册表编辑器(regedit.exe),滚动到:

HKEY_CURRENT_USER\Software\Trolltech\Versions\DefaultQtVersion

HKEY_CURRENT_USER \ SOFTWARE \奇趣\版本\ DefaultQtVersion

and edit it to current version number. Check other entries in Trolltech group, to make sure they are set to current version. That solved the problem of

并将其编辑为当前版本号。检查Trolltech组中的其他条目,以确保它们设置为当前版本。这解决了问题

Unable to find a Qt build! To solve this problem specify a Qt build

无法找到Qt版本!要解决此问题,请指定Qt构建

for me.

为了我。