Qt for msvc problem
-
It’s my first time working with msvc for Qt. I wrote the most basic code for test cpp file and cmakelist.txt.
- cmake doesn’t see any problems - it find all necessary paths
- clion doesn’t highlight code for cpp file
the last error that was shown before freezing windows was during debug, missing qt6 dll’s. So I used windeployqt to copy them to build dir.
I use:
-
Qt 6.8.2 for msvc_20223
-
msvc 2022 x64
-
compiling with cmake provided with msvc
-
I tried compiling it manually under Visual Studio Prompt. It doesn’t change anything. I don’t think it’s IDE problem
-
all paths in cmakelist.txt are correct
-
windows environment vars has QTDIR C:\Qt\6.8.2\msvc2022_64 and msvc in Path var
At this point I don't know what to do
Note: I wanted to replicate this error to state before I used windeployqt, before it started to crash to get a full error message. I made a new project the same as before. Even before copying dll’s it crashes windows on run or debug.
CMakeList.txt
cmake_minimum_required(VERSION 3.25) project(test_msvc_2) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) #set(CMAKE_PREFIX_PATH "C:/Qt/6.8.2/msvc2022_64/") set(QT_PATH "C:/Qt/6.8.2/msvc2022_64") #set(CMAKE_PREFIX_PATH ${QT_PATH}/lib) set(CMAKE_PREFIX_PATH ${QT_PATH}/lib/cmake/Qt6) message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets WebEngineCore WebEngineWidgets WebChannel) add_executable(test_msvc_2 main.cpp) target_link_libraries(test_msvc_2 PRIVATE Qt6::Core Qt6::Gui Qt6::Widgets Qt6::WebEngineWidgets Qt6::WebEngineCore Qt6::WebChannel)
main.cpp
#include <QApplication> #include <QWebengineView> int main(int argc, char *argv[]) { QApplication app(argc, argv); QWebEngineView view; view.setUrl(QUrl("https://www.qt.io")); view.show(); return app.exec(); }
-
@Dot79677
You do not give us the details of what exactly/happens.Even before copying dll’s it crashes windows on run or debug.
If your program crashes, nothing to do with deployment, sort that out first. If you can get it to crash from a debugger show the stack trace.
Btw, does it go wrong if you replace the
QWebEngineView
with something else, like a plain widget/label? -
@JonB said in Qt for msvc problem:
does it go wrong if you replace the QWebEngineView with something else,
If I replace it with QWidget it works fine. But I need QWebEngine.
How can I show you any debugger info when as soon as I run it in debug (cLion) it freezes entire system. Only hard reboot works. It doesn't show any messages before it.
Its very confusing. I've been trying to set up qt with msvc for a long timen now. I've gone thru many iteration of cmakelist code before it started compiling. Last thing that happened before crashing system was that it was comppiling. Cmake nor Clion showed any error. On bebug I got messages of missing dll's QWidgets, QCore etc. I copied them to project's build foder. After that it started to crash. Moreover it crashes when I put the same code into new files in new project (without copeying dll's).