Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved] QML import path
albanj last edited by
Please excuse the newb question. I suspect it's already been answered somewhere but I'm not really sure what to search for.
I've followed the instructions to make and install "Bacon2D":https://github.com/Bacon2D/Bacon2D and that seemed to work ok.
If I create a Qt Quick UI project I can put
@importPaths: [ "/home/alec/Qt/imports" ]@
in the .qmlproject file. This works and I can use the plugin.
I've been trying to do the same with a Qt Quick Application project so I can build and test on Android. I imagine I need to use the .pro file and QML_IMPORT_PATH but haven't managed to get it working. I've tried paths to the import folder in my Qt directory, the Bacon2d directory downloaded and built. I'm not sure what format this line needs or if this is the right/only thing to do.
QML debugging is enabled. Only use this in a safe environment.
QQmlImports(qrc:///main.qml)::addLibraryImport: "QtQuick" 2.2 as ""
QQmlImports(qrc:///main.qml)::importExtension: loaded "/home/alec/Qt/5.3/gcc_64/qml/QtQuick.2/qmldir"
QQmlImportDatabase::registerPluginTypes: "QtQuick" from "/home/alec/Qt/5.3/gcc_64/qml/QtQuick.2"
QQmlImports(qrc:///main.qml)::addLibraryImport: "QtQuick.Controls" 1.1 as ""
QQmlImports(qrc:///main.qml)::importExtension: loaded "/home/alec/Qt/5.3/gcc_64/qml/QtQuick/Controls/qmldir"
QQmlImportDatabase::registerPluginTypes: "QtQuick.Controls" from "/home/alec/Qt/5.3/gcc_64/qml/QtQuick/Controls"
QQmlApplicationEngine failed to load component
qrc:///main.qml:3 module "Bacon2D" is not installed@
Is the output from QML_INPUT_TRACE=1
Same situation on Lubuntu 14.04 and Manjaro 0.8.something
Can anyone point me in the right direction? Is there any extra info I can give?
shav last edited by
I use this code:
int main(int argc, char *argv)
Application app(argc, argv);
QtQuick2ControlsApplicationViewer viewer; viewer.addImportPath(Application::applicationDirPath()+"/com/shav/msl"); viewer.addImportPath(Application::applicationDirPath()+"/com/shav/msl/qmldir"); viewer.setMainQmlFile(QStringLiteral("qml/MslEditor/main.qml")); viewer.show(); return app.exec();
In QML files I've added this:
import com.shav.msl 1.0
albanj last edited by
Well I'm thoroughly confused.
I got up this morning happy to see shav's post. I go to try it out but everything is already working. The only thing I can think of is that a system restart made Qt rejigger itself and recognise the stuff in its imports folder.
Thanks shav for your reply.
I'll mark the topic solved because I no longer have the problem. Marking it 'Waste of Everybody's Time' might be better though!