librehat / yapstocks

Yet Another Plasma Stocks Applet
GNU General Public License v3.0
22 stars 7 forks source link

Type PriceChart unavailable / module "QtCharts" is not installed #5

Closed zeraien closed 4 years ago

zeraien commented 4 years ago

Tried version 1.0, 2.1 and 3.0.

Fedora 32 Plasma: 5.18.5 KDE Frameworks: 5.70 Qt: 5.14.2

Error loading QML file: file:///home/zeraien/.local/share/plasma/plasmoids/com.librehat.yapstocks/contents/ui/main.qml:157:9: Type PriceChart unavailable
file:///home/zeraien/.local/share/plasma/plasmoids/com.librehat.yapstocks/contents/ui/PriceChart.qml:23:1: module "QtCharts" is not installed

This was also done:

Installed:
  qt5-qtcharts-5.14.2-1.fc32.x86_64

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 ;-)

librehat commented 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?

zeraien commented 4 years ago

After a reboot, it works.

snjee commented 3 years ago
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.

librehat commented 3 years ago
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?

snjee commented 3 years ago

"... 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

vasilzhigilei commented 2 years ago

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.