最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

c++ - qt for msvc basic setup crashes windows - Stack Overflow

programmeradmin6浏览0评论

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 when I run main.cpp file even on debug it freezes windows

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(";));
    view.show();

    return app.exec();
}
发布评论

评论列表(0)

  1. 暂无评论