How to fix "Missing QML.Element class info for XXX"?
-
Hello, I am discovering the QML world. What I would like to do is to add this example inside a more general application, i.e. this example would be one widget among others.
So I have defined a QQuickWidget inside which I try to load the example.
Here is the related code that is located in the constructor of my main widget (a little bit adapted from the one given in the example)#ifdef Q_OS_WIN QString extraImportPath(QStringLiteral("%1/../../../../%2")); #else QString extraImportPath(QStringLiteral("%1/../../../%2")); #endif ui->graphQuickWidget->engine()->addImportPath( extraImportPath.arg(QGuiApplication::applicationDirPath(), QString::fromLatin1("qml"))); //! [2] QQmlContext *context = ui->graphQuickWidget->engine()->rootContext(); context->setContextProperty("myGraph", m_myGraph); ui->graphQuickWidget->setSource(QUrl("HMI/qml/components/graphFrequencies/main.qml")); ui->graphQuickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView);
My problem is that when I run my program, I get several messages that are followed by a crash
Missing QML.Element class info for QAbstractAxis
Missing QML.Element class info for QAreaSeries
Missing QML.Element class info for QBarCategoryAxis
Missing QML.Element class info for QBarModelMapper
Missing QML.Element class info for QBarSeries
Missing QML.Element class info for QBarSet
Missing QML.Element class info for QDateTimeAxis
Missing QML.Element class info for QLineSeries
Missing QML.Element class info for QPieModelMapper
Missing QML.Element class info for QPieSeries
Missing QML.Element class info for QPieSlice
Missing QML.Element class info for QScatterSeries
Missing QML.Element class info for QSplineSeries
Missing QML.Element class info for QValueAxis
Missing QML.Element class info for QXYModelMapper
Missing QML.Element class info for QXYSeriesI do not know how to solve this problem. Do you have any advice for me?
-
What is causing the crash? Try to run your program with a debugger.
-
The crash is caused by the line
seriesList: myGraph.pieSeries
inmain.qml
More precisely, the debugguer says me that the problem happens in the
QGraphsView::insertSeries
(internal method) because the QGraphsView object isnullptr
.So far, here is my understanding. All the "Missing QML.Element" messages are displayed when I add the line
import QtGraphs
in main.qml. Because it seems that nothing is loaded correctly, theGraphsView
is not created which finally provokes the crash.So I guess that if I fix the "Missing QML.Element" messages, everything will work fine.
-
Are you using a
QGuiApplication
or aQApplication
? You should be using the latter.