Generate a qmltypes file from QML components and not C++ like qmlplugindump
-
wrote on 29 Nov 2012, 18:26 last edited by
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 -
wrote on 29 Nov 2012, 18:54 last edited by
IIRC creator will just parse .qml files that the user imports. No dumping should be necessary.
-
wrote on 30 Nov 2012, 08:31 last edited by
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 -
wrote on 30 Nov 2012, 16:26 last edited by
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.
-
wrote on 2 Dec 2012, 16:04 last edited by
So there is no way to publish a closed-source library that contains elements written in QML with support for qmltypes?
-
wrote on 19 Apr 2013, 14:44 last edited by
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.
-
wrote on 19 Apr 2013, 15:27 last edited by
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.
-
wrote on 22 Apr 2014, 22:07 last edited by
One year later :p
But have the solution
@qmlplugindump -nonrelocatable My.Module 1.0 > plugins.qmltypes@ -
wrote on 22 Apr 2014, 22:21 last edited by
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?
-
wrote on 23 Apr 2014, 06:34 last edited by
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.
-
wrote on 24 Apr 2014, 08:53 last edited by
Nice, thanks!
I'll try to do that and then mark this thread as solved.