CMake failed to load QWebWidgets module
-
@jsulm
Would you mind to teach me where to put it?cmake_minimum_required(VERSION 3.5) project(dev-mini VERSION 0.1.0 LANGUAGES CXX ) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core) find_package(QT NAMES Qt6 REQUIRED COMPONENTS Gui) find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets) find_package(Qt6 REQUIRED COMPONENTS Widgets) find_package(QT NAMES Qt6 REQUIRED COMPONENTS WebEngineWidgets) set(PROJECT_SOURCES global/error.hpp global/error.cpp ui/object.hpp ui/object.cpp ui/mainwindow.hpp ui/mainwindow.cpp ui/translator.hpp ui/translator.cpp ui/workspace.hpp ui/workspace.cpp ui/icon.hpp ui/icon.cpp main.cpp ) set(PROJECT_RESOURCES resource/icon.qrc ) qt_add_executable(dev-mini MANUAL_FINALIZATION ${PROJECT_SOURCES} ${PROJECT_RESOURCES} ) target_link_libraries(dev-mini PRIVATE Qt6::Widgets) target_link_libraries(dev-mini PRIVATE Qt6::WebEngineWidgets) set_target_properties(dev-mini PROPERTIES MACOSX_BUNDLE_GUI_IDENTIFIER dev.starlight.work/product/dev-mini MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} MACOSX_BUNDLE TRUE WIN32_EXECUTABLE TRUE ) install(TARGETS dev-mini BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) qt_finalize_executable(dev-mini)
-
@KaiKai said in CMake failed to load QWebWidgets module:
qt_add_executable(dev-mini
You already have it. Did you add it after my suggestion or was it already there but you get that CMake error?
-
Excuse me to insist but: which compiler are you using ?
-
@KaiKai Ell, you could also simply show what compiler is set in the Kit, but from the last screen-shot it is at least visible that you're using MinGW. To use WebEngine you have to use Microsoft compiler (because the used Google Chromium engine only supports Microsoft compiler). So, you have to install Microsoft Visual Studio (or build tools) and Qt for Microsoft compiler.
-
@jsulm I have changed the compiler to MSVC. Everything else has been successful, but CMake has not found this module so far.
find_package(Qt6 REQUIRED COMPONENTS WebEngineWidgets)
D:\Code\C++\project\dev-mini\dev-mini\ui\workspace.hpp:9: error: C1083: 无法打开包括文件: “QtWebView/QWebEngineView”: No such file or directory D:\Qt\Tools\CMake_64\share\cmake-3.23\Modules\CMakeFindDependencyMacro.cmake:47: warning: Found package configuration file: D:/Qt/6.2.4/msvc2019_64/lib/cmake/Qt6WebEngineCore/Qt6WebEngineCoreConfig.cmake but it set Qt6WebEngineCore_FOUND to FALSE so package "Qt6WebEngineCore" is considered to be NOT FOUND. Reason given by package: Qt6WebEngineCore could not be found because dependency Qt6WebChannel could not be found. D:/Qt/6.2.4/msvc2019_64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:14 (find_dependency) D:/Qt/6.2.4/msvc2019_64/lib/cmake/Qt6WebEngineWidgets/Qt6WebEngineWidgetsDependencies.cmake:96 (_qt_internal_find_dependencies) D:/Qt/6.2.4/msvc2019_64/lib/cmake/Qt6WebEngineWidgets/Qt6WebEngineWidgetsConfig.cmake:40 (include) D:/Qt/6.2.4/msvc2019_64/lib/cmake/Qt6/Qt6Config.cmake:209 (find_package) CMakeLists.txt:22 (find_package)
-
D:\Qt\6.2.4\msvc2019_64\lib\cmake\Qt6\Qt6Config.cmake:209: warning: Found package configuration file: D:/Qt/6.2.4/msvc2019_64/lib/cmake/Qt6WebEngineCore/Qt6WebEngineCoreConfig.cmake but it set Qt6WebEngineCore_FOUND to FALSE so package "Qt6WebEngineCore" is considered to be NOT FOUND. Reason given by package: Qt6WebEngineCore could not be found because dependency Qt6Positioning could not be found. CMakeLists.txt:22 (find_package) D:\Code\C++\project\dev-mini\dev-mini\CMakeLists.txt:22: error: Found package configuration file: D:/Qt/6.2.4/msvc2019_64/lib/cmake/Qt6/Qt6Config.cmake but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT FOUND. Reason given by package: Failed to find Qt component "WebEngineCore". Expected Config file at "D:/Qt/6.2.4/msvc2019_64/lib/cmake/Qt6WebEngineCore/Qt6WebEngineCoreConfig.cmake" exists :-1: error: CMake process exited with exit code 1. :-1: error: CMake returned error code: 1
-
I met the same error as you did. And it seems that the reason of my situation is because:
WebEngineWidgets
has aWebEngineCore
dependency- but
WebEngineCore
cannot find itsPositioning
dependency.
Therefore, after I install "Qt Positioning" module in Qt Maintainance Tools, the error disappeared.
-
@Haowei-Hsu you saved my day ^^. Thank you. Qt Positioning really fix this issue on my Qt 6.8