Qt 5.9 中的 QML 崩溃 - 帮助读取堆栈跟踪

2022-01-19 00:00:00 qt5 qt qml qtcharts c++

我正在使用 Qt 5.9 编写一个应用程序,顶部带有 C++ 主界面和 QML UI.一切都很好(包括从 C++ 向 QML 发送信号),但是当我将 ChartView 添加到 UI 时,我看到了崩溃.ChartView 的精简版如下所示;当我从代码中省略它时,不会崩溃.

I am writing an app using Qt 5.9 with C++ main and QML UI on the top. Everything fine (including sending signals from C++ to QML) but when I?add ChartView to the UI, I am seeing a crash. The stripped-down version of the ChartView looks like the following; when I omit it from the code, no crash.

ChartView {
    id: _chartView
    LineSeries {
        name: "avgZ"
        XYPoint { x: 0; y: 0}
    }
}

这是堆栈跟踪(通过出色的 backward-cpp):

This is the stack trace (via excellent backward-cpp):

Stack trace (most recent call last):
#27   Object "", at 0xffffffffffffffff, in 
#26   Object "/home/eudoxos/pw/carxx/build/main-qt", at 0x561cceac54a9, in _start
#25   Source "/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c", line 310, in __libc_start_main [0x7fafdf218b96]
#24   Object "/home/eudoxos/pw/carxx/build/main-qt", at 0x561cceac849b, in main
#23   Object "/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5", at 0x7fafe297761c, in QQmlApplicationEngine::load(QUrl const&)
#22   Object "/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5", at 0x7fafe29775dd, in QQmlApplicationEnginePrivate::startLoad(QUrl const&, QByteArray const&, bool)
#21   Object "/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5", at 0x7fafe2977372, in QQmlApplicationEnginePrivate::finishLoad(QQmlComponent*)
#20   Object "/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5", at 0x7fafe28f974e, in QQmlComponent::create(QQmlContext*)
#19   Object "/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5", at 0x7fafe28fb407, in QQmlComponentPrivate::beginCreate(QQmlContextData*)
#18   Object "/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5", at 0x7fafe2984c6b, in QQmlObjectCreator::create(int, QObject*, QQmlInstantiationInterrupt*)
#17   Object "/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5", at 0x7fafe298197b, in QQmlObjectCreator::createInstance(int, QObject*, bool)
#16   Object "/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5", at 0x7fafe2980ba5, in QQmlObjectCreator::populateInstance(int, QObject*, QObject*, QQmlPropertyData const*)
#15   Object "/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5", at 0x7fafe2983e10, in QQmlObjectCreator::setupBindings(bool)
#14   Object "/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5", at 0x7fafe29833d9, in QQmlObjectCreator::setPropertyBinding(QQmlPropertyData const*, QV4::CompiledData::Binding const*)
#13   Object "/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5", at 0x7fafe2981145, in QQmlObjectCreator::createInstance(int, QObject*, bool)
#12   Object "/usr/lib/x86_64-linux-gnu/libQt5Qml.so.5", at 0x7fafe2910961, in QQmlType::create(QObject**, void**, unsigned long) const
#11   Object "/usr/lib/x86_64-linux-gnu/qt5/qml/QtCharts/libqtchartsqml2.so", at 0x7faf9632485a, in qt_plugin_instance
#10   Object "/usr/lib/x86_64-linux-gnu/qt5/qml/QtCharts/libqtchartsqml2.so", at 0x7faf963452a5, in QByteArray::reserve(int)
#9    Object "/usr/lib/x86_64-linux-gnu/libQt5Charts.so.5", at 0x7faf95ffc51e, in QtCharts::QChart::mapToPosition(QPointF const&, QtCharts::QAbstractSeries*)
#8    Object "/usr/lib/x86_64-linux-gnu/libQt5Charts.so.5", at 0x7faf95ff7975, in 
#7    Object "/usr/lib/x86_64-linux-gnu/libQt5Charts.so.5", at 0x7faf95ff683e, in 
#6    Object "/usr/lib/x86_64-linux-gnu/libQt5Charts.so.5", at 0x7faf95ff368c, in 
#5    Object "/usr/lib/x86_64-linux-gnu/libQt5Charts.so.5", at 0x7faf95ff2fe2, in 
#4    Object "/usr/lib/x86_64-linux-gnu/libQt5Charts.so.5", at 0x7faf9600045f, in QtCharts::QAbstractSeries::qt_metacall(QMetaObject::Call, int, void**)
#3    Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5", at 0x7fafa2d85a5c, in QGraphicsTextItem::document() const
#2    Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5", at 0x7fafa2d8571e, in non-virtual thunk to QGraphicsTextItem::focusOutEvent(QFocusEvent*)
#1    Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5", at 0x7fafa2c7e311, in QWidgetTextControl::QWidgetTextControl(QObject*)
#0    Object "/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5", at 0x7fafa2c7e235, in QWidgetTextControl::setCursorWidth(int)
Segmentation fault (Address not mapped to object [(nil)])
Segmentation fault (core dumped)

任何人都可以在堆栈跟踪中找到一些可能导致崩溃的提示吗?

Can anyone find some hint in the stack trace what could be causing the crash?

我能够毫无问题地运行带有折线图的 QML 示例.

I was able to run QML examples with line charts without any issue.

推荐答案

如果你要使用 Qt Charts 你必须将 QGuiApplication 更改为 QApplication 并添加 QT += 小部件 到 .pro

If you are going to use Qt Charts you must change the QGuiApplication to QApplication and add QT += widgets to .pro

相关文章