Closed zeraien closed 4 years ago
You need the QML module of QtCharts. Not sure about Fedora these days, but on OpenSUSE it's libqt5-qtcharts-imports
And when I checked the package of Fedora, it seems that qt5-charts
does provide libqtchartsqml2.so
... So you might need a re-login?
After a reboot, it works.
int main(int argc, char *argv[])
{
// Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used.
QApplication app(argc, argv);
QQuickView viewer;
// The following are needed to make examples run without having to install the module
// in desktop environments.
#ifdef Q_OS_WIN
QString extraImportPath(QStringLiteral("%1/../../../../%2"));
#else
QString extraImportPath(QStringLiteral("%1/../../../%2"));
#endif
viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(),
QString::fromLatin1("qml")));
//***** [Solve] FORCE THE MODULE TO BE IMPORTED.
QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close);
qDebug() << viewer.engine()->importPathList();
viewer.setTitle(QStringLiteral("QML Axes"));
viewer.setSource(QUrl("qrc:/qml/qmlaxes/main.qml"));
viewer.setResizeMode(QQuickView::SizeRootObjectToView);
viewer.show();
return app.exec();
}
[Output through qDebug()] ("/home/snjee/workspace_qt/maxelecPrjs/build-maxCoffeeTdsMeterApp-Desktop_Qt_5_15_2_GCC_64bit-Debug", "qrc:/qt-project.org/imports", "/opt/Qt/5.15.2/gcc_64/qml")
You can find the answer in the built-in "QML Axes" example source.
int main(int argc, char *argv[]) { // Qt Charts uses Qt Graphics View Framework for drawing, therefore QApplication must be used. QApplication app(argc, argv); QQuickView viewer; // The following are needed to make examples run without having to install the module // in desktop environments. #ifdef Q_OS_WIN QString extraImportPath(QStringLiteral("%1/../../../../%2")); #else QString extraImportPath(QStringLiteral("%1/../../../%2")); #endif viewer.engine()->addImportPath(extraImportPath.arg(QGuiApplication::applicationDirPath(), QString::fromLatin1("qml"))); //***** [Solve] FORCE THE MODULE TO BE IMPORTED. QObject::connect(viewer.engine(), &QQmlEngine::quit, &viewer, &QWindow::close); qDebug() << viewer.engine()->importPathList(); viewer.setTitle(QStringLiteral("QML Axes")); viewer.setSource(QUrl("qrc:/qml/qmlaxes/main.qml")); viewer.setResizeMode(QQuickView::SizeRootObjectToView); viewer.show(); return app.exec(); }
[Output through qDebug()]
("/home/snjee/workspace_qt/maxelecPrjs/build-maxCoffeeTdsMeterApp-Desktop_Qt_5_15_2_GCC_64bit-Debug", "qrc:/qt-project.org/imports", "/opt/Qt/5.15.2/gcc_64/qml")
You can find the answer in the built-in "QML Axes" example source.
Look up, this is a plasmoid widget, not a standalone Qt application. Besides, why should an application bundle its dependencies when the system can resolve them?
"... is not installed" "found not working imports...." I have now found the correct solution. All problems were solved. => Solutions : https://stackoverflow.com/questions/22320541/import-qtquick-controls-2-1-qml-module-not-found
Quick tip for Arch/Manjaro users: the correct package is qt5-charts (sudo pacman -S qt5-charts
), and YAP Stocks should work after a reboot.
Tried version 1.0, 2.1 and 3.0.
Fedora 32 Plasma: 5.18.5 KDE Frameworks: 5.70 Qt: 5.14.2
This was also done:
Only thing I haven't tried is a reboot/relog, although that seems a bit overkill, but I'll eat my hat if it works after my next reboot in a few weeks ;-)