QQmlComponent:组件尚未准备好 - 模块“QtCharts”未安装

问题描述 投票:0回答:1

我正在尝试在主页上呈现 QtCharts 示例:

import QtCharts

...

        ChartView {
            title: "Line Chart"
            anchors.fill: parent
            antialiasing: true

            LineSeries {
                name: "Line"
                XYPoint {
                    x: 0
                    y: 0
                }
                ...
            }
        }

我的机器上有 QtCharts 和 QQmlCharts(Ubuntu 24.04 - 一切都通过

apt
安装):

/usr/lib/x86_64-linux-gnu/libQt6ChartsQml.so.6
/usr/lib/x86_64-linux-gnu/libQt6Charts.so.6.4.2
/usr/lib/x86_64-linux-gnu/libQt6ChartsQml.so.6.4.2
/usr/lib/x86_64-linux-gnu/libQt6ChartsQml.so
/usr/lib/x86_64-linux-gnu/libQt6Charts.so

linkage(使用cmake进行配置)看起来也不错:

/usr/bin/c++ CMakeFiles/app.dir/app_autogen/mocs_compilation.cpp.o CMakeFiles/app.dir/src/main.cpp.o CMakeFiles/app.dir/app_qmltyperegistrations.cpp.o CMakeFiles/app.dir/build/.rcc/qrc_qmake_application.cpp.o CMakeFiles/app.dir/src/hardware_tester.cpp.o CMakeFiles/app.dir/src/feature_table_model.cpp.o CMakeFiles/app.dir/build/.rcc/qmlcache/app_qmlcache_loader.cpp.o CMakeFiles/app.dir/build/.rcc/qmlcache/app_qml/Main_qml.cpp.o CMakeFiles/app.dir/build/.rcc/qmlcache/app_qml/HardwareTestScreen_qml.cpp.o CMakeFiles/app.dir/build/.rcc/qrc_app_raw_qml_0.cpp.o -o app   -L/home/guido/codes/application/lib/Hardware/lib/ftd2xx  -Wl,-rpath,/home/guido/codes/application/lib/Hardware/lib/ftd2xx: /usr/lib/x86_64-linux-gnu/libQt6Concurrent.so.6.4.2 /usr/lib/x86_64-linux-gnu/libQt6ChartsQml.so.6.4.2 lib/BusinessLogic/libBusinessLogicLib.a lib/Utilities/libUtilitiesLib.a lib/Hardware/libHardwareAbstractionLayerLib.a lib/Persistence/libPersistenceLib.a /usr/lib/x86_64-linux-gnu/libQt6Charts.so.6.4.2 /usr/lib/x86_64-linux-gnu/libQt6OpenGLWidgets.so.6.4.2 /usr/lib/x86_64-linux-gnu/libQt6Widgets.so.6.4.2 /usr/lib/x86_64-linux-gnu/libQt6Quick.so.6.4.2 /usr/lib/x86_64-linux-gnu/libQt6QmlModels.so.6.4.2 /usr/lib/x86_64-linux-gnu/libQt6Qml.so.6.4.2 /usr/lib/x86_64-linux-gnu/libQt6Network.so.6.4.2 /usr/lib/x86_64-linux-gnu/libQt6OpenGL.so.6.4.2 /usr/lib/x86_64-linux-gnu/libQt6Gui.so.6.4.2 /usr/lib/x86_64-linux-gnu/libQt6Core.so.6.4.2 /usr/lib/x86_64-linux-gnu/libGLX.so /usr/lib/x86_64-linux-gnu/libOpenGL.so ...

但是

*.so
没有链接:

$ ldd ./build/app | grep -i qt6
        libQt6Widgets.so.6 => /lib/x86_64-linux-gnu/libQt6Widgets.so.6 (0x00007f776f800000)
        libQt6Qml.so.6 => /lib/x86_64-linux-gnu/libQt6Qml.so.6 (0x00007f776f200000)
        libQt6Core.so.6 => /lib/x86_64-linux-gnu/libQt6Core.so.6 (0x00007f776ec00000)
        libQt6Gui.so.6 => /lib/x86_64-linux-gnu/libQt6Gui.so.6 (0x00007f776dc00000)
        libQt6Network.so.6 => /lib/x86_64-linux-gnu/libQt6Network.so.6 (0x00007f776e669000)
        libQt6DBus.so.6 => /lib/x86_64-linux-gnu/libQt6DBus.so.6 (0x00007f776e34b000)

当我运行应用程序时,我得到:

QQmlComponent: Component is not ready
qrc:/application/qml/Main.qml:10:5: QML StackView: push: qrc:/application/qml/HardwareTestScreen.qml:1 module "QtCharts" is not installed

为什么会发生这种情况?

在机器中,我还成功编译并运行了一个使用 QtCharts 但带有 QtWidgets(不带 Qml)的应用程序。

c++ linux qt qml
1个回答
0
投票

您必须在 CMAKE 文件中添加 Charts 包:

find_package(Qt6 REQUIRED COMPONENTS Charts)
target_link_libraries(mytarget PRIVATE Qt6::Charts)
© www.soinside.com 2019 - 2024. All rights reserved.