简体   繁体   中英

How do I set up Qt paths in Visual Studio 2010?

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).

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

Unable to find a Qt build!

To solve this problem specify a Qt build

So I go to the Qt -> Qt Options menu item in VS and click 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

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?)

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.

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:

Could not find make command: make in the build environment

Error while building project untitled (target: Desktop)

When executing build step 'Make'

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

Qt version is not properly installed, please run make install

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

I'm running Windows 7 x64.

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.

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

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

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

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)

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

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

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.

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.

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:

HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\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

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

for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM