How to use Qt with Visual Studio Code? I have Qt 5.15.1 installed which builds my code for macOS, Android and iOS.
Is it possible to have Visual Studio Code build my Qt application for macOS, Android and iOS like QtCreator does?
Environment:
My developer environment is macOS Catalina.
If you're using cmake, which you should, then all you need to do is configure your cmake project to point to your Qt folder, which basically means setting the project's Qt5_dir env variable to point to your Qt installation.
Here's what you need to do to get Visual Studio Code to work with Qt using Microsoft's CMake Tools extension:
Verify that you really have Qt installed,
Install Microsoft's CMake Tools extension,
Open CMake Tools extension's "Edit CMake Cache (UI)"
click on "CMake extension" on vscode's activity bar to open "CMake: project outline",
click on the "View and more actions" button (i.e., elipsis on upper right corner of the project outline.
Edit CMake's cache to point Qt5_dir to ${QTINSTALLDIR}/5.15.1/gcc_64/lib/cmake/Qt5
Rebuild project.
You can achieve the same goal by using cmake-gui to configure your cmake project.
If instead you really want to stick with qmake then it's enough to setup a build task that runs qmake.
Related
I am trying to install Qt4.8.7 for Windows 10 and I am having some issues with installing the corresponding compiler.
I got the Qt4.8.7 installer from this link: https://download.qt.io/archive/qt/4.8/4.8.7/ and I have tried working with the MSVC2010 and the mingw versions. For the MSVC2010 version, I followed this guide https://wiki.qt.io/How_to_setup_MSVC2010 (with a lot of dead links) and installed the compiler alongside the MSVC service pack 1 and Windows SDK 7.1. I have not been able to find an installer for Visual Studio 2010 or the VS service pack 1. Qt studio recognises the version of qt I have installed alongside the corresponding MSVC2010 x86 compiler but when I compile I get this error for a missing header: "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\intrin.h:26: error: C1083: Cannot open include file: 'ammintrin.h': No such file or directory".
For the mingw version, I have not been able to find the correct version "mingw482" and other versions I have tried do not seem to be compatible. I have tried mingw installer programs as well as using the QT online installer to try and find the correct version but I haven't had much luck when compiling.
Has anyone got qt4.8.7 running on windows recently? If so, could you please point me in the right direction for installing the correct compiler?
Many thanks.
Here a short description for getting it to work with Visual Studio 2008 and the newest Qt Creator 4.13.
You will need:
Visual Studio 2008 Express for the build tools, there are no standalone build tools as far as I'm aware
Qt 4.8.7 precompiled for VS2008 from this link to Qt archives at the time of writing this the version you need is called "qt-opensource-windows-x86-vs2008-4.8.7.exe"
Any Windows debugger cdb.exe
Steps (all absolute paths are standard installation paths):
Install VS2008
Install Qt 4.8.7
Open your Qt Creator go to Tools->Options...->Kits->Tab Compilers and search for "Microsoft Visual C++ Compiler 9.0", it probably won't be there so you will need to add it by hand by looking for the vcvarsall.bat of this compiler. You will find it in C:/Program Files(x86)/Microsoft Visual Studio 9.0/VC/vcvarsall.bat. Repeat for C, C++, x86 and x64. Press save
Open the Qt-Versions tab and look for Qt 4.8.7 Version. It will probably not be there again so add it by hand by selecting the qmake.exe from C:/Qt/4.8.7/bin/qmake.exe. Press save
Open the Kits tab and add a new kit. Select your Qt 4.8.7 version and the MS compilers for C and C++, your favorite debugger and input the Qt-makespec win32-msvc2008. Press save again
Now you should be able to compile your project from Qt Creator and Qt-colored-commandline. For integration of MSVC 9.0 into Visual Studio 2015 and newer you will also need to install Visual Studio 2012 Express. In that order:
VS2008
VS2012 (Here MS programmed in some magic so newer VS can see older build tools)
VS201x
It could work in any other order but don't rely on it. Also it could just flat out not work and you will waste a week of your life to fix it; but then it will work.
Haven't tested it but I could imagine the same workflow will work for VS2010.
I am setting up Qt using CLion and build project successfully.
But the problem comes when I try to run it, which it does not run because it can't find the Qt Library.
When using QtCreator, I don't need to setup anything to run Qt project (it does automatically). So, how QtCreator run the project? So I can achieve it on CLion?
Already set PATH to Qt bin, but it does not work.
I'm trying to get QT to work with Visual Studio Express 2013.
As first I downloaded sources, and was trying to compile it using Developer Command Prompt for VS2013. Gave up, after adding to QT source files new things, to keep compiler move on.
After that I just installed QT binaries. The QT: "qt-windows-opensource-5.1.1-msvc2012-x86_64-offline.exe"
It has it's own editor, but I would like to use QT inside Visual Studio Express 2013. Can I just link libraries, from Visual Studio Express 2013 project?
I linked C:\Qt\2010.05\qt\include to the Include, C:\Qt\2010.05\qt\lib to the libraries and C:\Qt\2010.05\qt\bin.
But there are a lot os subdirectories, that Visual doesn't include.
Should I wait for QT Sources compatible with Visual Studio Express 2013?
Or can I use it now, like that?
Regards
To do this from cmd.exe you have to edit your PATH by adding QtDir/bin there, then cd to your project directory and write the line written before.
Everything should looks like this:
Run cmd.exe
cd your_project_dir/
qmake -spec win23-msvc2010 -tp vc
After this manipulations you will have .vcproject file in your project directory
So I thought upgrading Qt and Qt Creator was a good idea since I used an older version of both.
I re-installed everything as I should and realized that Qt 5 is only for VS2010 for Windows which I have never worked with since I have been sticking with minGW up to this point,
I then realized my problems that my project wouldn't compile and run so I tried to download the 4.8.4 version with minGW, but that complained that:
"The installer could not find a valid c:\MinGW32\include\w32api.h
(Only versions with W32API3.13 are supported)"
and further I did not get creator when I installed it either.
Any help that would either let me go back to 4.8.8 minGW or a simple straight forward way using Qt creator with VS2010 would be appreciated, thanks.
I think I solved parts of my own issue (at least enough to answer this problem).
1: Download and install latest minGW installer and add ';C:\MinGW\bin' to the system variable 'path'.
2: Download the Qt 4.8.4 and install it (Does not come with Qt Creator) and add'C:\Qt\4.8.4\bin' to the system variable 'path'.
3: Download the latest Qt Creator, launch it and go:
tools -> options -> build & run
From there choose the correct Qt version by pointing to the Qmake in the Bin folder (C:\Qt\4.8.4\bin in this case)
Also make sure it auto detects minGW compiler, if it does not show up I am not sure what to do.
4: If you are including a project from other Qt versions you might have to delete the users.pro file (not the .pro file) to get it to compile properly.
Last issue is that I do not have any debugger, but the program compiles in the /release folder (if you put CONFIG += release in the pro file) and I can run it by using the .exe.
Using MSVS 2010 as the compiler isn't too hard.
Download Visual Studio Express 2010.
Install it, and now you have MSVS 2010 compiler available.
The compiler should be located under C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin or somewhere similar at cl.exe.
Setting up the latest version of Qt built against MSVC 2010, with the latest Qt Creator isn't too bad, either. In Tools > Options > Build and Run > Kits, find your Qt qmake installation, and in Tools > Options > Build and Run > Compiler, find your compiler.
Now you can use the amazing Qt 5 instead of sticking in the past with 4.8 (even though Qt 4.8 is awesome and works really well, too).
Hope that helps.
I'm trying to import my Cmake project in QtCreator, which I'd want to use as code editor, but with completition for Qt classes an the possibility to do the build via Ctrl+R
When importing the Cmake project, the QtCreator ide hangs when running CMakeWizard when I try to select RunCmake. If I cancel an empty windows pops up and the project is not generated.
Is it possible to import an existing cmake project in QtCreator?
Ubuntu 10.10 x86_64, QtCreator 2.6
Normally you just do "Open Project" and then select the CMakeLists.txt as the project file. QtCreator will then ask you to run CMake once (to generate a CodeBlocks build file, which is then interpreted by QtCreator). After that you have native support for your CMake project.
It even works with rather complicated CMake scripts.
If you observe hangs etc., you should probably file a bug report with the QtCreator project.
I had a similar issue when qtcreator crashed when opening cmake projects created in older versions of qtcreator. Removing CMakeLists.txt.user and running qt from terminal resolved issue for me.
cd /path/to/project/
qtcreator .