How do you set up your .pro file with Qt Tools for Visual Studio?
-
The screenshot shows that I tried copying over some of the QtCreator .pro file side to the VS side. In VS I right-clicked the project, there's a context menu folder for Qt, and within it is "Create .pro file". So I did that and edited that, but I don't think VS is using the .pro file in the build! So what is the point of the create .pro file....
Anyway, how did you end up getting your Qt app to build? Mine uses webenginewidgets, which is one of the reasons I wanted the .pro file on the VS side.
Here's currently the generated .pro file with my edits:
# ---------------------------------------------------- # This file is generated by the Qt Visual Studio Tools. # ------------------------------------------------------ TEMPLATE = app TARGET = AbstractSpacecraft DESTDIR = ./x64/Debug CONFIG += debug LIBS += -L"." DEPENDPATH += . MOC_DIR += . OBJECTS_DIR += debug UI_DIR += . RCC_DIR += . include(AbstractSpacecraft.pri) win32:RC_FILE = AbstractSpacecraft.rc QT += core gui QT += webenginewidgets webchannel greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++17 PRECOMPILED_HEADER = precompiledheader.pch CONFIG += precompile_header
-
https://stackoverflow.com/a/5234347/7076615
I think that is the issue. In Qt Creator you don't include the PCH everywhere, in VS you have to!
-
Now, I've figured out on my own that you're supposed to add in Qt modules using the VS C++ build settings under "Additional Qt modules". There's a Select Qt modules and a GUI pops up with checkable boxes and the Qt logo on each checkbox. WebEngine Widgets, etc was there. So I deleted my .pri, .pro files and now having issues with the precompiled header. So we're getting somewhere!
It says we forgot to add "#include "stdafx.h"" to the source code, but it's right at the top of main.cpp.
I will try adding back in the .pro file again and assigning precompiled header there as well. Has anyone encountered this hurdle?
-
https://stackoverflow.com/a/5234347/7076615
I think that is the issue. In Qt Creator you don't include the PCH everywhere, in VS you have to!
-
OMG! It works now! ;-)
And it runs promptly. I think I will like debugging in VS more than in Qt Creator.
-
@enjoysmath said in How do you set up your .pro file with Qt Tools for Visual Studio?:
I think I will like debugging in VS more than in Qt Creator.
The standalone Microsoft debugger is horrible. I mostly use VS for debugging on Windows. Qt Creator can only be used on smaller projects with tiny data for debugging. Still, we are using .pro files as a basis as we compile on different platforms. qmake can generate a VS project from your .pro file automatically. Only the dependencies in the resulting VS project are not perfect.
I guess the future is CMake. It's portable and both Qt Creator and VS understand it. (But, it requires Qt 6.)
-
@SimonSchroeder cmake also supports Qt 5.