[Qt-interest] qml plugins location problem

David Heremans david.heremans at intersoft-electronics.com
Wed May 11 16:24:20 CEST 2011


Hello all,

In an attempt to on-the-fly create Linux/windows/mac independent GUIs
that could be served by a central server we are trying out QML.
We created a C++ class "QMLBaseWidgets" that holds some custom widgets
coded in Qt/C++ that should be callable from QML.
Some simple proof of concepts were working fine, but now we ran into the
following problem, and we hope that somebody here could shed a light on
the subject.

If we download the generated qml into /tmp/ and we create a file
'/tmp/qmldir' and a subdirectory /tmp/QMLBaseWidgets containing
libQMLBaseWidgets.so, this all works nicely.

However when trying to store the qmldir and
QMLBaseWidgets/libQMLBaseWidgets.so in a different directory
(/opt/QMLhelpers/) this fails, and the application output shows

file:///tmp/UDP_Input.1.0.1.qml:2:1: "QMLBaseWidgets": no such directory
     import "QMLBaseWidgets" 1.0


This is the code that instantiates the view

	//our own xmlrpc helper for qml code
	qmlRegisterType<XMLRPCClient>("XMLRPC", 1, 0, "XMLRPCClient");

	QDeclarativeView* view=new QDeclarativeView();

	//adding  "/opt/QMLhelpers/" to the paths
	QSettings settings;
	settings.beginGroup("QML");
	view->engine()->addImportPath(settings.value("Dir","/opt/QMLhelpers/").toString());
	view->engine()->addPluginPath(settings.value("Dir","/opt/QMLhelpers/").toString());
    	
view->rootContext()->setContextProperty("myHost",QString("127.0.0.1"));
	view->rootContext()->setContextProperty("myPort",6666);

	view->setSource(QUrl::fromLocalFile(m_qmlAbsolutePath));
	view->show();


And this is the header of the generated qml file

	import Qt 4.7
	import QMLBaseWidgets 1.0
	import XMLRPC 1.0



I tried playing with qmlviewer with -I and -P options but the output of
the debugger was as follows
$ QML_IMPORT_TRACE=1  qmlviewer -I /opt/QMLhelpers/ -I . -P
/opt/QMLhelpers/ -P . UDP_Input.1.0.1.qml
QDeclarativeImportDatabase::addImportPath "/usr/lib/qt4/imports"
QDeclarativeImportDatabase::addImportPath "/usr/bin"
QInotifyFileSystemWatcherEngine::addPaths: inotify_add_watch failed: No
such file or directory
QFileSystemWatcher: failed to add paths: /home/david/.config/ibus/bus
Bus::open: Can not get ibus-daemon's address.
IBusInputContext::createInputContext: no connection to ibus-daemon
QDeclarativeImportDatabase::addImportPath "/opt/QMLhelpers/"
QDeclarativeImportDatabase::addImportPath "."
QDeclarativeImportDatabase::addPluginPath "/opt/QMLhelpers/"
QDeclarativeImportDatabase::addPluginPath "."
QDeclarativeImportDatabase::addToImport 0x106bfe0 "." -1.-1 File as ""
QDeclarativeImportDatabase::addToImport 0x106bfe0 "Qt" 4.7 Library as ""
QDeclarativeImportDatabase::addToImport 0x106bfe0 "QMLBaseWidgets" 1.0
Library as ""
file:///tmp/UDP_Input.1.0.1.qml:2:1: module "QMLBaseWidgets" is not
installed
     import QMLBaseWidgets 1.0
     ^

I have been trying all kind of combinations of -I and -P but alas...
Can somebody please tell me what I'm doing wrong? Thanks!


rgds,

David H




More information about the Qt-interest-old mailing list