QmlPluginDump errors with 'cannot create a QWidget without QApplication'

一个人想着一个人 提交于 2020-01-06 06:32:11

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!