Setting up Visual Studio 2019 for creating QT6 projects
-
Greetings.
I have been using Visual Studio 2019 for well over a year to create my QT 5.xx.xx projects in preference to using QT creator. I have downloaded QT6 and successfully run a few of the QT6 demos to test that all is well in QT creator. However I prefer to use visual studio 19 for all my coding and compiling and have found that the latest version of the QT Visual Studio tools (that looks to be a product of the QT company) seems to not offer a setup template for creating a QT6 project.
I have attempted to set up a QT6 project using the latest version of QT VS tools, and changed the QTDIR environmental variable to match the path to the QT6 directories as I have done in the past when updating QT to a new version. When I compile a simple QT application template to display a QT window, as I do when setting up a new project, I get an error
ERROR running qmake.
I know QT6 is abandoning qmake in favor of cmake, but I would have thought that qmake was only a part of creating and compiling QT code within QT Creator, not visual studio, and thus not used.
So my question is should I need to wait for a new version of QT VS tools to be released and not use QT VS tools to setup a visual studio QT6 project?
If so, When can a new version of QT VS tools be expected to be released with QT6 project templates?
I am about to attempt to manually create a Visual Studio project to utilise QT6 and create a QT6 project template using the demos and some QT5 manually setup projects as a guide. Is there any advice I need to follow or information to do this correctly such as a new particular library that is in some obscure location and not easy to detect as being mandatory for all projects? QT6 is so recent I just cannot find anything to help in this regard.
Any help would be appreciated.
Thanks
-
Ok, Failed to manually set up Visual Studio 2019 to use QT6 as expected. Not surprised as I have never been able to do this in the past, And I have little to no knowledge of using Cmake, so no complaints.
However, I had decided to upgrade Qt 5.15.1 to 5.15.2 and did this without a problem. Once that was done, I uninstalled Qt 5.15.1
Then I decided to try creating a new QT6 project and try out a few things using QT creator for QT6. Well, blow me down, now nothing works and I get a message
The CMAKE_CXX_COMPILER:
P:/Productivity/Programing/QT_5_15/Tools/QtCreator/bin/clang/bin/clang-cl.exe
is not a full path to an existing compiler tool.
Even the examples now have this error occurring.
But this is a path name to an old installation that I uninstalled months ago.As suggested by the error message displayed, I created a CXX environmental variable with the correct path name to this file in my QT6 installation. The Error still occurred.
Then, also as suggested I created a "CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler"
which according to online Cmake documentation is of the formset(<variable> <value>... CACHE <type> <docstring> [FORCE])
so using my total non familiarity with Cmake I entered
set(CMAKE_CXX_COMPILER P:/Productivity/Programing/QT6/Tools/QtCreator/bin/clang/bin/clang-cl.exe CACHE FILEPATH [FORCE])
into the CMakeLists.txt file.
Did not solve the problem. It seems to me that there are still a few problems to be ironed out with setting up QT6 using CMake. I am sure there is some file or variable created during installation that this error originates from, but where is and how to fix it is a mystery to me right now. If anyone can help with where this path name is stored so I can modify it, I would much appreciate it.
I being a user of QT who does not have a familiarity with dealing with Cmake and does not in any way want to even touch Cmake files, as every attempt in the past has lead to disaster, I hope that QT6 will be more friendly towards Cmake novices in future releases.
Regards
-
well I'm facing the same problem (a little different in some ways)
I'm using it with Qt 5.15.1 for over an year, I just updated my Qt VS Tool to 2.8.1 and then tried to add Qt 6.2.2 to my visual studio, but I keep getting this error after adding it--- qmake(6352): started D:\QT\QT-6.2.2-MSVC2019-X86_64\bin\qmake.exe --- qmake: Querying persistent properties --- qmake(6352): exit code 0 (406.59 msecs) Value cannot be null. Parameter name: path1 Stacktrace: at System.IO.Path.Combine(String path1, String path2, String path3) at QtVsTools.Core.QMakeConf..ctor(VersionInformation versionInfo, QMakeQuery qmakeQuery) at QtVsTools.Core.VersionInformation.GetQMakeConfEntry(String entryName) at QtVsTools.Options.QtVersionsPage.SaveSettingsToStorage() in C:\dev\source\qtlabs\vstools\QtVsTools.Package\Options\QtVersionsPage.cs:line 93
so what is the problem and why I cant add Qt6.2.2 to my visual studio?
-
after Visual studio upgdade and Qt VS Tools upgrade facing same problem, with no solution found.
tried uninstalling, reinstalling Visual studio and also using older Qt VS Tools. with no luck.
(qt 5.12.5)--- qmake(10540): started C:\PROGRAM FILES\XXXXXXXX\XXXXXXXX\xxx\qmake.exe
--- qmake: Querying persistent properties
--- qmake(10540): exit code 0 (29.31 msecs)Value cannot be null.
Parameter name: path1Stacktrace:
at System.IO.Path.Combine(String path1, String path2, String path3)
at QtVsTools.Core.QMakeConf..ctor(VersionInformation versionInfo, QMakeQuery qmakeQuery)
at QtVsTools.Core.VersionInformation.GetQMakeConfEntry(String entryName)
at QtVsTools.Options.QtVersionsPage.SaveSettingsToStorage() in C:\dev\source\qtlabs\vstools\QtVsTools.Package\Options\QtVersionsPage.cs:line 93 -
Sad to see that people have so many issues with this :/ Anyhow, it seems to me that some of them have different causes.
I have attempted to set up a QT6 project using the latest version of QT VS tools, and changed the QTDIR environmental variable
to match the path to the QT6 directories as I have done in the past when updating QT to a new version. When I compile a simple
QT application template to display a QT window, as I do when setting up a new project, I get an errorERROR running qmake.
The QTDIR variable is AFAIK not used anymore since Qt 4 days. In Qt VS tools, you register Qt versions under Extensions > Qt VS Tools > Qt Versions. Have you tried setting it there?
Note also that there has been some bug fixes in the latest Qt VS Tools release related to Qt 6, so I suggest making sure you have the latest version installed first.
Ok, Failed to manually set up Visual Studio 2019 to use QT6 as expected. Not surprised as I have never been able to do this in
the past, And I have little to no knowledge of using Cmake, so no complaints.Note that using CMake is an orthogonal question. You can both use qmake and CMake with Qt 6. If you use CMake, you can choose either to use the native support Visual Studio has for CMake, or generate .sln/.proj files via the VIsual Studio generator in CMake.
The CMAKE_CXX_COMPILER:
P:/Productivity/Programing/QT_5_15/Tools/QtCreator/bin/clang/bin/clang-cl.exe
is not a full path to an existing compiler tool.
Even the examples now have this error occurring.
But this is a path name to an old installation that I uninstalled months ago.If the path is really invalid, you probably have had already tried to configure your project back when it was valid. In contrast to qmake, CMake does try to cache some results across runs. Hunt for a CMakeCache.txt file in your build directory and delete it to have a fresh start.
You can btw override CMake variables either on the cmake command line:
cmake -D CMAKE_C_COMPILER=<somepath> -D CMAKE_CXX_COMPILER=<somepath>
or by using a tool like cmake-gui after the project was (ill-)configured once. But it's easiest to just make sure that no other clang.exe or clang-cl.exe is in your PATH, because CMake has the annoying behavior to prefer Clang over MSVC, even on Windows.
--- qmake(6352): started D:\QT\QT-6.2.2-MSVC2019-X86_64\bin\qmake.exe
--- qmake: Querying persistent properties
--- qmake(6352): exit code 0 (406.59 msecs)Value cannot be null.
Parameter name: path1Can you try running
qmake -query
manually, from command line? Does it succeed there?
-
This post is deleted!
-
One previously(Qt5.11.2) added working correctly. Even without activating it Visual Studio picking and using it. Is there any cache to remove?
Unable to add new qt version in Qt VS Tools.--- qmake(10408): started C:\QT\QT5.12.5\5.12.5\MSVC2017_64\bin\qmake.exe
--- qmake: Querying persistent properties
--- qmake(10408): exit code 0 (62.66 msecs)vcvars: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat
cl: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.30.30705\bin\HostX64\x64\cl.exe
--- qmake(9236): started C:\QT\QT5.12.5\5.12.5\MSVC2017_64\bin\qmake.exe
--- qmake: Working Directory: C:\Users\xxxxxxxx\AppData\Local\Temp\js2muf1m.fqe
--- qmake: Arguments: QMAKE_INCDIR_QT=$(QTDIR)\include QMAKE_LIBDIR=$(QTDIR)\lib QMAKE_MOC=$(QTDIR)\bin\moc.exe QMAKE_QMAKE=$(QTDIR)\bin\qmake.exe -o "js2muf1m.fqe.vcxproj" -tp vc -Wnone "js2muf1m.fqe.pro"
Info: creating stash file C:\Users\xxxxxxxx\AppData\Local\Temp\js2muf1m.fqe.qmake.stash
ASSERT: "uint(i) < uint(size())" in file c:\users\qt\work\qt\qtbase\include\qtcore../../src/corelib/tools/qstring.h, line 936
--- qmake(9236): exit code -1073740791 (2293.29 msecs)Error reading VS project settings
Stacktrace:
at QtVsTools.Core.VersionInformation..ctor(String qtDirIn)
at QtVsTools.Core.VersionInformation.Get(String qtDir)
at QtVsTools.Options.QtVersionsPage.SaveSettingsToStorage() in C:\dev\source\qtlabs\vstools\QtVsTools.Package\Options\QtVersionsPage.cs:line 93