Szymson
Szymson

Reputation: 1122

Chart in QML[QChart.js]

Hi I was looking for chart in QML i found QChart.js I done the tutorial how import the Chart.js to my project but it doesn't work i get error:

module "jbQuick.Charts" is not installed.

When in qml i have:

import jbQuick.Charts 1.0

I store my qml files in qrc:

<RCC> <qresource prefix="/"> <file>ActualValues.qml</file> <file>LoginScreen.qml</file> <file>test.qml</file> <file>VoltageHistory.qml</file> <file>CurrentIntensityHistory.qml</file> <file>VoltagePlot.qml</file> <file>CurrentIntensityPlot.qml</file> </qresource> </RCC>

How can I import the chart or which I could use ?

Upvotes: 1

Views: 3193

Answers (2)

albertTaberner
albertTaberner

Reputation: 2149

I manage to make it work by adding:

*.pro

QML_IMPORT_PATH += qml

main.cpp

engine.addImportPath(QStringLiteral("jbQuick/Charts"));
engine.addImportPath(QStringLiteral("qml"));

Finally, and the most important part: You should copy your folder "jbQuick" (the one which contains the "Charts" subfolder) into your qml compiler folder.

For instance, you should have:

WINDOWS -> C:\Qt\5.5\mingw492_32\qml\jbQuick\Charts
MAC-> /Users/XXX/Qt/5.5/clang_64/qml/jbQuick/Charts

I hope this helped someone.

Upvotes: 1

arxarian
arxarian

Reputation: 397

you have to write down the relative or absolute path to QCharts.js in your .pro file

QML_IMPORT_PATH += ../path_to_jbQuick_parent_folder

The structure of jbQuick folder should look like

jbQuick
   -Charts
      -QCharts.js
      -QChart.qml
      -qmldir
      - ...

You also have set the path to QCharts.js in your QQmlApplicationEngine instance

addImportPath("../path_to_jbQuick_parent_folder")

Now, you can import QCharts.js in QML file

import jbQuick.Charts 1.0

Your question is also answered here

Upvotes: 6

Related Questions