Solved I cant import and use Qtcharts in qml file
-
qrc:/main.qml:3 plugin cannot be loaded for module "Qtcharts": Module namespace 'QtCharts' does not match import URI 'Qtcharts'
this is the error..
and these are my codes
import QtQuick 2.8 import QtQuick.Window 2.2 import Qtcharts 2.2 Window { visible: true visibility: "FullScreen" title: qsTr("Hello World") }
#include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); }
-
@sierdzio
thanks a lot.
but why my Qt doesn't auto complete?!
I mean, I should write the import QtCharts 2.2 my self! -
@PooyaSis said in I cant import and use Qtcharts in qml file:
import Qtcharts 2.2
import QtCharts 2.2
Uppercase "c" :-)
-
@sierdzio
thanks a lot.
but why my Qt doesn't auto complete?!
I mean, I should write the import QtCharts 2.2 my self! -
@PooyaSis Qt Creator does auto complete QML imports for you, just type the first 4 characters and it should display the auto fill context menu. Unless it does not see the QtCharts module somehow. Have you installed it using the official installer?
-
@sierdzio
It's not displaying the auto fill for QtCharts 2.2!!! but it can recognize it...
I used MaintenanceTool for installing QtCharts ...
@mrjj
still I have problem with QtChartsmain.cpp
#include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec(); }
main.qml
import QtQuick 2.6 import QtQuick.Window 2.2 import QtCharts 2.2 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") ChartView { id: chartView backgroundColor: "transparent" legend.visible: false ValueAxis { id: valueAxisX min: 0 max: maxNumOfTempReadings + 1 visible: false } ValueAxis { id: valueAxisY min: minimum max: maximum visible: false } LineSeries { id: avgTempSeries axisX: valueAxisX axisY: valueAxisY color: chartColor } } }
-
For QtCharts, in documentation it says clearly:
Note: Since Qt Creator 3.0 the project created with Qt Quick Application wizard based on Qt Quick 2 template uses QGuiApplication by default. As Qt Charts utilizes Qt Graphics View Framework for drawing, QApplication must be used. The project created with the wizard is usable with Qt Charts after the QGuiApplication is replaced with QApplication.