Choosing MSVC toolchain - qt

I want to use QtCreator and MSVC as a compiler instead of MinGW. I successfully compiled Qt source code with MSVC 2010. As you would have guessed, I have MSVC 2010 installed on my machine. I also registered MSVC version of Qt in QtCreator, but now the problem is that I can’t select MSVC toolchain in qtcreator.
So far, I found out that QT_INSTALL_LIBS and QT_INSTALL_BINS are not correctly configured for MSVC version of qt binaries. I guess this could be the problem, but I don’t know how I should configure that variables.
Here's the screenshot

Check if you have define the environment variable QTDIR (this can be done in command line, using set command). This allows Qt Creator to auto-detect the value.
Also, could you try to rename the folder not using 'c++', instead use e.g. 'cplusplus', and see if this could also resolve the problem.

You need to set your QMAKESPEC environment variable to "win32-msvc2010" (or create the variable if you don't have it), then restart QtCreator. This tells Qt and QtCreator that you are using the msvc compiler of Visual Studio 2010 for 32bit windows applications.
That should do the trick.
PS: If you have any Windows Explorer windows open you need to close these too after setting the environment variable.
PPS: Press [windows-key][Pause] to quickly access the system properties dialog

Related

Unable to add QT version

I'm using QT for the first time to build a GUI. I'm following this Tutorial.
I followed the steps one by one as shown in the screenshot below.
Select the project
I selected Other project>>Empty qmake Project. Next I'm prompted to add the Kits.
Add Kits
I add the Kits, but in the next Tab "Qt Versions", there are no QT versions.
No QT Version
I figured i didn't install any QT Versions during the installation process. so I opened up the "Add or remove programs" and found that these are the components I have installed.
Installed components
Will these suffice to build a Desktop GUI using QT creator or are there any other components I have to install as well?
So, for a first try, I suggest using the MinGW compiler, since it is installed by Qt Maintenance Tool.
If you need to use the MSVC compiled Qt like the one selected in your pick, but you need also to install Visual Studio since you need the MSVC Compiler. If you also need to debug an MSVC Qt Application via QtCreator you need to manually configure the CDB, since the one installed with Visual Studio is not detected by Qt Creator.
Those pieces of information are related to MSVC2017 and Visual Studio 2017. If you intend to use MSVC2019 I don't know how QtCreator manages that.
About your situation is strange, you installed the MSVC Qt so they should be detected in QtCreator (tools -> options -> kits -> Qt Versions). I suggest to completely uninstall Qt and restart the process selecting just the MinGW 64-bit, QtCreator and MinGW Compiler 7.

setting up VS platfrom toolset in QtCreator

I have a project based on Qt which use QWebEngine. For compiling this project i've installed Visual Studio Express 2015 and have configured kits. My project is built, all is fine. But now i need to compile my project for Windows XP platform. I know, that for doing this it is needed to change toolset from v140 to v140_xp.
How can i set the toolset from qtcreator?
I tried to determine the difference in compiler options in both cases. For doing that I've created test project in Visual Studio. There i change the toolset and look at Project Properties -> C/C++ -> Command Line Options. But seems that nothing changes there.
Qt WebEngine module does not support Windows XP targeting, so this won't work anyway. Even if it did, you'd need to build a copy of Qt that targets Windows XP - otherwise your application will target Windows XP, but not the Qt library it uses, and it won't work that way.
For completeness sake, here's how you'd do it assuming that you got Qt built targeting Windows XP:
There only two ways to do it currently without patching Qt Creator itself:
Execute Qt Creator with environment variables already setup up for the XP toolset enabled for command line use. I.e. target XP from command line, and launch Qt Creator from there.
Add relevant environment variable settings to the Build environment of the project in Qt Creator.
The details of environment variables needed to target Windows XP are given e.g. here.
For Windows XP portability, you should be using the semi-maintained for of the qtwebkit module. It builds and works on XP, and works with most recent Qt IIRC.
Note: It's certainly possible to target XP using WebEngine and Angle, but it requires lots of patches to current Qt. It's not an insignificant effort, and you'd definitely want to test it on the graphics cards that you intend to target - the DirectX 9 drivers on some of those machines are buggy, and while the code is correct and compiles and runs, it may not work on some systems. I'd say that it's absolutely not worth the effort.
In VS there is an editbin utility, which could be used as follows
editbin file.exe /SUBSYSTEM:WINDOWS,5.01 /OSVERSION:5.1

Qt application not a valid 32bit application

I made a simple Qt application. Everything is working well on mt PC. I use Windows 7 SP1 and Qt Creator for building and debugging. When I try to run my program on Win XP I get the error "Not a valid 32 application". I had the same problem when I was making applications with Visual Studio 2012. However I fixed that problem with Visual Studio. In Tools -> Options I made it wo be compiling for Win XP. And everything was working on my PC and on the PC with XP. But I can't find such option in Qt Creator. How can I run my application on Windows XP?
Qt-Creator is only IDE, it uses compiler you tell it to use (I'm assuming it would be VS2012 in your case).
You can check compiler/linker flags in your other VS2012 solution that make a difference (what changes as you set "option compiling for Win XP" when you look to command line input to compiler/linker), and set same flags in your Qt .pro file.
You can see actual input to compiler/linker by going to project properties->C/C++->Command line and Linker->Commnd line respectively in your VS2012 project.
You can set compiler/linker flags in qt using
QMAKE_CXXFLAGS +=
and
QMAKE_LFLAGS +=
in qt .pro file respectively.

Installing Qt5.1.1 and making it run with Visual Studio 2010

I am trying to install Qt5.1.1 and have already installed VStudio 2010 Pro, but I stll get the error saying Qt needs a compiler set up to build.
I looked it up, and I only find very complex solutions that are impossible for me to implement.
Can anyone give me specific directions on how I can get Qt5.1.1 working in my laptop?
Btw in case you couldn't tell, I'm a newbie.
Thanks
First, ensure that your Visual Studio installation contains a 32-bit compiler (the official Visual Studio 2010 packages only support 32-bit compilers)
Then, ensure that you've downloaded and installed one of the packages that are marked "Qt 5.1.1 for Windows 32-bit (VS 2010)" from http://qt-project.org/downloads
If Qt Creator still doesn't auto-detect your compiler, add it manually: http://qt-project.org/doc/qtcreator-2.8/creator-tool-chains.html
If you had to add your compiler manually, also add a Kit to combine your compiler with your Qt libraries: http://qt-project.org/doc/qtcreator-2.8/creator-targets.html

Porting QT application from Linux to Windows?

Greetings all,
We are developing a QT application (QT 4.6 LGPL version) in Linux platform.All the libraries we use are cross-platform.
Now we want to port it into Windows and continue develop in Windows.
My questions are:
Which compiler should we use ,Can we use MinGW or Visual C++ compiler?
2.If its Visual C++ compiler, which Visual Studio version should be used ,can we use 'Visual C++ Studio 2010 express' ?
thanks in advance.
The easiest, by far, is to install QtCreator. it includes MinGW and simply opens the same project files as on linux. compile, and go!
A huge advantage of MinGW over VC++ is that it doesn't make you chase circles around getting the right vcredist library for the exact version of the compiler, nor it cares too much about debug/release builds. To deploy, just be sure to copy the same one or two DLLs you have on the development machine. A few more for Qt, but these are well-documented on Qt docs. No hidden surprises.

Resources