Using QML Modules with PluginsQML modules may use plugins to expose components defined in C++ to QML applications. Since Qt Creator cannot load the plugins to determine the details of the contained components, these modules need to provide extra type information for code completion and the semantic checks to work correctly. Ideally, QML modules have a plugins.qmltypes file in the same directory as the qmldir file. The qmltypes file contains a description of the components exported by the module's plugins and is loaded by Qt Creator when the module is imported. For Qt 4.8 and later, one or more qmltypes files can be listed in the qmldir file under the typeinfo header. These files will be read in addition to plugins.qmltypes. For more information, see Writing a qmldir File. Generating qmltypes FilesYou can create and edit qmltypes files manually, but you are recommended to use the qmlplugindump tool shipped with Qt 4.8 and later to generate them automatically. For earlier versions of Qt, you can compile a version of the tool called qmldump from the sources in <QtCreator>/share/qtcreator/qml/qmldump if the Qt version contains private headers. Once you have obtained qmlplugindump for the Qt version the QML module's plugins were compiled with, run the following command to load My.Module version 1.0 from /import/path/my/module including all its plugins and output a description of the plugins' types to /import/path/my/module/plugins.qmltypes: qmlplugindump My.Module 1.0 /import/path > /import/path/my/module/plugins.qmltypes You can safely ignore the debug output. Dumping Plugins AutomaticallyIf a module with plugins lacks the qmltypes file, Qt Creator tries to generate a temporary file itself by running the qmldump program in the background. However, this automatic dumping is a fallback mechanism with many points of failure and cannot be relied upon. [Previous: Implementing Application Logic] [Next: Developing Widget Based Applications] © 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. Privacy Policy Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia. Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. X
|