问题
I am trying to create the plugins.qmltypes file using qmlplugindump
as described here. It complains it cannot create a QWidget without QApplication
.
My folder structure looks like this:
~/imports/
- MyWidget/
- qmldir
- MyWidget.dll
I run the following command (from ~):
qmlplugindump MyWidget 1.0 import --output import/MyWidget/plugins.qmltypes
My qmldir file looks like:
module MyWidget # name to use in your qml which will use this plugin
plugin MyWidget # should match dll name
回答1:
To answer my own question, after browsing the code (on woboq) I found you can add the --qapp command line option so the qmlplugindump
tool will create a QApplication
(instead of QGuiApplication
see this question and answers)
My qmldir file looks now like:
module MyWidget # name to use in your qml which will use this plugin
plugin MyWidget # should match dll name
typeinfo plugins.qmltypes # created by qmlplugindump
Note, you also need to use the release build of your plugin, as the qmlplugindump file loads the dll, and is of course running the release, so that would result in mixing executables (luckily the error you will get is very clear)
来源:https://stackoverflow.com/questions/50984481/qmlplugindump-errors-with-cannot-create-a-qwidget-without-qapplication