Plugins.qmltypes

From Qt Wiki
Revision as of 15:48, 30 August 2018 by Kkoehne (talk | contribs)
Jump to navigation Jump to search

This page describes the purpose of plugins.qmltypes files, and now to update them.

Purpose

plugins.qmltypes files are used to describe the API a QML Module defines as QML metadata. It's main consumer is Qt Creator, which uses it for code completion and underlining errors etc.

Qt Creator looks for the file alongside the module itself. The qmldir file of the module can link to it with 'typeinfo <filepath>'. Although the name is actually free, the default is plugins.qmltypes, and giving it a different name just causes confusion.

Aside from the use in tooling, it is also a good place to do QML API reviews!

The file can be generated by the qmlplugindump command.

File Format

TODO

Updating plugins.qmltypes

qmake generates a 'qmltypes' target, that you can run. The platform shouldn't matter, as long as it is possible to load the QML import there!

Before dumping, please make sure that the IMPORT_VERSION set in the plugin .pro file is set correctly. This is done automatically for modules that follow the Qt minor version (like most in qtdeclarative).

For running the command on a whole subtree (for instance inside qtdeclarative/imports), go to the build dir of qtdeclarative and execute e.g.

 for path in `find . -name "Makefile*" -print`; do pushd `dirname $path`; make -f `basename $path` qmltypes; popd; done

Note that not all modules do work fine with qmlplugindump; In particular, crashes on exit are often seen. This does not imply though that the output is invalid.

FAQ

Q: 'make qmltypes' prints QQmlCOmponent: Component is not ready. A: This happens e.g. when the import version passed to qmlplugindump does not match the version registered at runtime. Inspect the sources for qmlRegisterXXXX calls, and set IMPORT_VERSION in the .pro file accordingly.