Link failed when using QQuickMaterialStyle in Qt6.4
Unsolved
QML and Qt Quick
-
Environment:
- openSUSE leap 15.5
- Qt 6.4 from openSUSE's repository
I add these modules in CMakeLists.txt:
Qt6::Quick Qt6::QuickPrivate Qt6::QuickControls2 Qt6::QuickControls2Private Qt6::QuickControls2Impl Qt6::QuickControls2ImplPrivate Qt6::QuickTemplates2 Qt6::QuickTemplates2Private
And with these lines in my sources:
# In the .h #include <QtQuickControls2/private/qquickmaterialstyle_p.h> # In the .cpp QQuickMaterialStyle * underlying = ....; underlying->setTheme(QQuickMaterialStyle::System);
Then, compile is ok, but link is failed with the following info:
x86_64-suse-linux/bin/ld: ../xxx/xxx/libDemo.so: undefined reference to `QQuickMaterialStyle::staticMetaObject'
I also tried adding this to target_link_libraries():
/usr/lib64/qt6/qml/QtQuick/Controls/Material/libqtquickcontrols2materialstyleplugin.so
But it's not work.If using Qt6.6, the extra CMake modules make it linkable, but no such modules for Qt6.4
So, how to fix this problem?