how to use qmltc with Qt6.4
-
Hi, I want to use new qmltc funcionality in my Qt application.
I type it as said in :and somehow i get this error when CMake is run:
- /home/pureqt/Qt/6.4.0/gcc_64/lib/cmake/Qt6Gui/Qt6GuiTargets.cmake:85: error: The link interface of target "Qt6::GuiPrivate" contains: XKB::XKB but the target was not found. Possible reasons include: * There is a typo in the target name. * A find_package call is missing for an IMPORTED target. * An ALIAS target is missing. /home/pureqt/Qt/6.4.0/gcc_64/lib/cmake/Qt6Gui/Qt6GuiConfig.cmake:52 (include) /home/pureqt/Qt/Tools/CMake/share/cmake-3.24/Modules/CMakeFindDependencyMacro.cmake:47 (find_package) /home/pureqt/Qt/6.4.0/gcc_64/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:108 (find_dependency) /home/pureqt/Qt/6.4.0/gcc_64/lib/cmake/Qt6Quick/Qt6QuickDependencies.cmake:39 (_qt_internal_find_qt_dependencies) /home/pureqt/Qt/6.4.0/gcc_64/lib/cmake/Qt6Quick/Qt6QuickConfig.cmake:40 (include) /home/pureqt/Qt/6.4.0/gcc_64/lib/cmake/Qt6/Qt6Config.cmake:213 (find_package) CMakeLists.txt:8 (find_package)
my CMakeList.txt looks like this:
cmake_minimum_required(VERSION 3.24)
project(my_qmltc_example VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)find_package(Qt6 6.4 COMPONENTS Quick REQUIRED)
qt_add_executable(appmy_qmltc_example
main.cpp
)qt_add_qml_module(appmy_qmltc_example
URI my_qmltc_example
VERSION 1.0
QML_FILES main.qml
ENABLE_TYPE_COMPILER
)set_target_properties(appmy_qmltc_example PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)target_link_libraries(appmy_qmltc_example
PRIVATE Qt6::Quick Qt6::QmlPrivate Qt6::QuickPrivate)install(TARGETS appmy_qmltc_example
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})I know that it doesnt support all modules in qml yet but this is actually totaly empty ("hello word") application, which I wanted to use it to learn it.
-
@mv-whw Hello there!
I am not too familiar with the error but it seems you might be missing the XKB::XKB dependency. Did you install the libxkb dev headers?
Also, I think that you should do
find_package(Qt6 6.4 COMPONENTS Quick Qml REQUIRED)
to find the Qml and QmlPrivate modules for the target_link_library() call. -
sudo apt-get install build-essential libgl1-mesa-dev
solved the issue for me.