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

QML2_IMPORT_PATH not working?



  • Hi.
    I am trying to run the qmltests test program from bluez-qt.
    I cross-built from source and deployed bluez-qt to the Pi4 in /usr/local.

    The tests are being built alright, but are not automatically deployed, so I copied them manually to /home/pi/test-bluez-qt/bin and additionally copied the autotests dir from the bluez-qt source dir to it, to have access to the tst_***.qml files apparently required by qmltests.

    Then, I try to run qmltests as follows:

    pi@raspberrypi:~/test-bluez-qt$ QML_IMPORT_TRACE=1 LD_LIBRARY_PATH=/home/pi/test-bluez-qt/bin QML2_IMPORT_PATH=/usr/local/lib/qml ./bin/qmltests
    

    This gives the following output:

    QQmlImportDatabase::addImportPath: "/usr/local/Qt5.15.2/qml"
    QQmlImportDatabase::addImportPath: "/home/dirac/build-bluez-qt-Pi4B-Debug/autotests/../src/imports"
    QQmlImportDatabase::addImportPath: "qrc:/qt-project.org/imports"
    QQmlImportDatabase::addImportPath: "/home/pi/test-bluez-qt/bin"
    QQmlImports(file:///home/pi/test-bluez-qt/bin/autotests/qml/tst_adapter.qml)::addLibraryImport: "QtTest" 1.0 as ""
    QQmlImports(file:///home/pi/test-bluez-qt/bin/autotests/qml/tst_adapter.qml)::importExtension: loaded "/usr/local/Qt5.15.2/qml/QtTest/qmldir"
    QQmlImportDatabase::registerPluginTypes: "QtTest" from "/usr/local/Qt5.15.2/qml/QtTest"
    QQmlImports(file:///home/pi/test-bluez-qt/bin/autotests/qml/tst_adapter.qml)::addLibraryImport: "QtQuick" 2.2 as ""
    QQmlImports(file:///home/pi/test-bluez-qt/bin/autotests/qml/tst_adapter.qml)::importExtension: loaded "/usr/local/Qt5.15.2/qml/QtQuick.2/qmldir"
    QQmlImportDatabase::registerPluginTypes: "QtQuick" from "/usr/local/Qt5.15.2/qml/QtQuick.2"
    QQmlImports(file:///home/pi/test-bluez-qt/bin/autotests/qml/tst_adapter.qml)::addLibraryImport: "org.kde.bluezqt.fakebluez" 1.0 as ""
    file:///home/pi/test-bluez-qt/bin/autotests/qml/tst_adapter.qml:10:1: module "org.kde.bluezqt" is not installed
         import org.kde.bluezqt 1.0 as BluezQt
         ^
    pi@raspberrypi:~/test-bluez-qt$
    

    The error is:

    file:///home/pi/test-bluez-qt/bin/autotests/qml/tst_adapter.qml:10:1: module "org.kde.bluezqt" is not installed
         import org.kde.bluezqt 1.0 as BluezQt
         ^
    

    However, the path set in QML2_IMPORT_PATH i.e. /usr/local/lib/qml contains the org.kde.bluezqt module:

    pi@raspberrypi:/usr/local/lib/qml/org/kde/bluezqt$ ls
    DevicesModel.qml  libbluezqtextensionplugin.so  qmldir
    pi@raspberrypi:/usr/local/lib/qml/org/kde/bluezqt$
    

    and qmldir is as follows:

    pi@raspberrypi:/usr/local/lib/qml/org/kde/bluezqt$ cat qmldir
    module org.kde.bluezqt
    plugin bluezqtextensionplugin
    
    DevicesModel 1.0 DevicesModel.qml
    

    How can I resolve this?
    Thanks!



  • I ended up copying the org dir to the ~/test-bluez-qt/bin dir so that it is in the default module search path as described at
    https://doc.qt.io/qt-5/qtqml-syntax-imports.html#qml-import-path

    I could also have copied the whole module dir to my Qt installation's qml dir in /usr/local/Qt5.15.2/qml, as suggested by the trace output from the above test:

    QQmlImportDatabase::addImportPath: "/usr/local/Qt5.15.2/qml"
    

    The qml test then runs correctly.
    But still no idea why using the QML2_IMPORT_PATH does not work


Log in to reply