when try import qtcharts module qml files y same warning message:
"found not working imports: file: c:/.... module "qtcharts" not installed"
i'm using opensource qtcreator 4.0.3 qt 5.7.0.
i have folder qtcharts in path: c:\qt\5.7\mingw53_32\qml
i've included folder path using property in .pro file:
qml2_import_path: c:\qt\5.7\mingw53_32\qml
what missing?
here simple test code:
// qtchartstest.pro
template = app qt += qml quick qt += charts config += c++11 sources += main.cpp resources += qml.qrc # additional import path used resolve qml modules in qt creator's code model qml2_import_path = c:\qt\5.7\mingw53_32\qml # default rules deployment. include(deployment.pri)
// main.cpp
#include <qguiapplication> #include <qqmlapplicationengine> int main(int argc, char *argv[]) { qguiapplication app(argc, argv); qqmlapplicationengine engine; engine.load(qurl(qstringliteral("qrc:/main.qml"))); return app.exec(); }
// main.qml
import qtquick 2.7 import qtquick.window 2.2 import qtcharts 2.1 window { visible: true width: 640 height: 480 title: qstr("hello world") text { text: qstr("hello world") anchors.centerin: parent } }
i stuck on similar issue , frustrated qt's documentation on subject, i'll put method of solving own issues here posterity.
i'm not sure of exact cause of issue, can offer suggestion try , troubleshoot it.
in main.cpp add following line. qdebug()<<engine.importpathlist();
so main be
#include <qguiapplication> #include <qqmlapplicationengine> #include <qdebug> int main(int argc, char *argv[]) { qguiapplication app(argc, argv); qqmlapplicationengine engine; qdebug()<<engine.importpathlist(); engine.load(qurl(qstringliteral("qrc:/main.qml"))); return app.exec(); }
this include complete list of include paths. if not see include path listed there can add adding following line:
engine.addimportpath(directory);
where "directory" qstring include directory.
my understanding qml2_import_path
variable applies @ run time, , not @ compile time, means qtcreator not see path when compiles. engine.addimportpath(directory);
on other hand adds path prior starting qml engine, (and first qml import statements)
i not saying best way solve issue, did me solve issue.
Comments
Post a Comment