c++/QML issues with CMake setup generated by QtCreator
-
Hi Everyone,
I'm currently struggeling with the idea behind the automatic C++/QML registration. I've implemented a simple example C++ object like described here:https://doc.qt.io/qt-6.2/qtqml-cppintegration-topic.html
The generated moc code isn't finding my header file, which is at the same level as the main.cpp.
Could someone be so kind and point me into the right direction? Do I have to move the C++ class into a special named folder?
Thanks and Best Fred
-
Hi,
Are you using qmake or CMake ?
Can you show your project file content ? -
@SGaist I'm using CMake.
cmake_minimum_required(VERSION 3.21.1) option(LINK_INSIGHT "Link Qt Insight Tracker library" ON) option(BUILD_QDS_COMPONENTS "Build design studio components" ON) project(testAppApp LANGUAGES CXX) set(CMAKE_AUTOMOC ON) find_package(Qt6 6.2 REQUIRED COMPONENTS Core Gui Qml Quick) if (Qt6_VERSION VERSION_GREATER_EQUAL 6.3) qt_standard_project_setup() endif() qt_add_executable(testAppApp src/main.cpp src/theorb.h src/theorb.cpp) qt_add_resources(testAppApp "configuration" PREFIX "/" FILES qtquickcontrols2.conf ) target_link_libraries(testAppApp PRIVATE Qt6::Core Qt6::Gui Qt6::Qml Qt6::Quick ) if (BUILD_QDS_COMPONENTS) include(${CMAKE_CURRENT_SOURCE_DIR}/qmlcomponents) endif() include(${CMAKE_CURRENT_SOURCE_DIR}/qmlmodules) include_directories(${CMAKE_SOURCE_DIR}/src) #added by myself if (LINK_INSIGHT) include(${CMAKE_CURRENT_SOURCE_DIR}/insight) endif () include(GNUInstallDirs) install(TARGETS testAppApp BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
I've added the include ./src by myself. This is working but without it the generated QML type registration code is compaining about the include file:
-
Looks like you are working with Qt Design Studio rather than Qt Creator, aren't you ?
-
@FredJupiter Is there a reason why you're using a beta version of Qt creator?
-
@FredJupiter The current stable for example