Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

importing QtCharts in QML causes “module not installed error” and app crash



  • First time playing around with Qt I encountered a problem. When I try to import QtCharts it shows me that it's not installed.

    I created a Qt quick app and from the dropdown I add QtCharts. it gives me an error(picture below). Despite the error I can drop the chart control in the window, the program seems to compile and crashes on run

    ![11:56:43: The program has unexpectedly finished.
    11:56:43: The process was ended forcefully.]
    

    The module is installed(I checked all boxes on installation), I tried reinstalling it several times. I tried installing different versions of Qt(5.14 and 5.12)

    I added to the project file

    QT += charts
    

    When I load an example project, for example qmlaxes, everything works fine. Despite the "not installed" message also being there.

    everything seems to be working fine when I create a C++ app though

    adding to *.pro didn't help

    QT += widgets
    

    I already had

    #include <QtWidgets/QApplication>
    

    as the documentation says

    ed389625-d905-4656-a3fd-15eb9a205afd-image.png image url)



  • @Bari

    Ok, but did you change all instances of the QGuiApplication?

    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        QApplication app(argc, argv); //Here etc..
    


  • Hey,

    Did you enable the qt charts module from the configuration list when installing Qt?

    2a1b7c8b-00b0-4996-97c5-10edc8893955-image.png

    You can check this and add it by using the Qt Maintenance tool.

    Edit;
    Read your post again, noticed you already had checked if it was installed.
    I would try to remove and install the component again, and if that does not work, I'd file a bug report :)

    Maybe someone else has a clue



  • yeah I tried that with several different versions.
    I get the same error message when I load an example and try to edit it except it compiles and runs

    maintenence



  • Hmm, I tried qcharts now, and examples work fine.
    But just copying the qml chart example code to my own qml app makes the app crash, as yours do.

    Though I do not get any messages about the module not being loaded, so might be a different issue.
    Will take a look at this when I wake up, as I plan to make use of charts in the future



  • @Bari

    Good morning!

    At the Qt Charts documentation page, it says:
    "Note: Projects created with Qt Creator's Qt Quick Application wizard are based on the Qt Quick 2 template that uses QGuiApplication by default. All such QGuiApplication instances in the project must be replaced with QApplication as the module depends on Qt's Graphics View Framework for rendering."

    So when I replaced QGuiApplication in main,cpp with QApplication that did the trick for me :)



  • yeah I did that, it's still the same

    #include <QApplication>
    


  • @Bari

    Ok, but did you change all instances of the QGuiApplication?

    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        QApplication app(argc, argv); //Here etc..
    


  • o turnes out I missed one.
    I went to change QQmlApplicationEngine also but it gave me an error so I reverted one to many changes.

    thanks!!



  • @Bari aha! :)

    No problem, glad i could help!


Log in to reply