Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved QML2_IMPORT_PATH not working?

    QML and Qt Quick
    1
    2
    196
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Diracsbracket
      Diracsbracket last edited by Diracsbracket

      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!

      Diracsbracket 1 Reply Last reply Reply Quote 0
      • Diracsbracket
        Diracsbracket @Diracsbracket last edited by Diracsbracket

        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

        1 Reply Last reply Reply Quote 0
        • First post
          Last post