Generate a qmltypes file from QML components and not C++ like qmlplugindump
-
Hi,
I have the following use-case:QtCreator allows auto-completion of C++ items from plugins, if a .qmltypes file was created for it with the qmlplugindump tool. However, what to do if I have components written in QML which I would like to distribute as a plugin?
I tried calling the qmlplugindump tool for the qml components as described in http://qt-project.org/doc/qt-4.8/qdeclarativemodules.html#writing-a-qmltypes-file, but an empty qmltypes file is the result. So it seems qmlplugindump is only applicable for C++ items. Are there other tools to generate a qmltypes file from QML files, or how could I generate the file so my components are usable from QtCreator?
Cheers,
Chris -
IIRC creator will just parse .qml files that the user imports. No dumping should be necessary.
-
Hi Tobias,
QtCreator can resolve the component definition when the qml sources are available that's right - however, I would like to distribute the plugin without the source code of the qml files. Thus I would like to generate qmltypes files from the qml sources.
Thanks,
Chris -
I am not really good with QML, sorry, but I would be surprised if that is possible.
The QML files are evaluated at runtime to do whatever they do. If you remove those files, then the functionality is gone.
-
So there is no way to publish a closed-source library that contains elements written in QML with support for qmltypes?
-
Any more word on this? The documentation indicates that it should work with just QML files, but it doesn't seem to be working for me either.
-
No I couldn't find any way to extract qmltype information from QML components :(
If you discover a way how to do this, please share it here.
-
One year later :p
But have the solution
@qmlplugindump -nonrelocatable My.Module 1.0 > plugins.qmltypes@ -
Does this also work for qml files in the plugin? I guess you would need to define the plugin then with the qmldir file, or are there any other requirements?
-
Yes I only have qml files in my qml plugin.
I'm not sure how it works, but I build a qml plugin with only qml files (styled controls) and deployed that plugin in the Qt5.3 install tree.
Then this command dropped me the correct plugins.qmltypes to enable color completion in qtcreator.Have a look at qtquick.controls module sources, in their qmltypes files i noted the command that generated the file.
-
Nice, thanks!
I'll try to do that and then mark this thread as solved. -
@feldifux : I know its been pretty late xD but did you find any solution as I am facing currently the same problem? I tried everything possible but somehow just have an empty qmltypes generated by the qmlplugindump.