Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.11.2
-
None
-
* Qt 5.11.2 (official)
* MSVC 2015 32 bit
* Windows 10 64 bit
Description
I have created my custom QML static plugin, derived from QQmlExtensionPlugin:
== plotlib.cpp ==
... ... const char kPlottingPluginUri[] = "com.my.plotting"; class PlottingPlugin final : public QQmlExtensionPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid FILE "plotlib.json") public: explicit PlottingPlugin(QObject* parent = nullptr) : QQmlExtensionPlugin(parent) { qDebug() << "*** CREATED"; } void registerTypes(const char *uri) final { Q_ASSERT(QLatin1String(uri) == QLatin1String(kPlottingPluginUri)); Q_UNUSED(uri); ... ... } }; #include "plotlib.moc"
Where the JSON file has the following content:
== plotlib.json ==
{ "uri": [ "com.my.plotting" ] }
Next, I load this plugin from my app in the following way:
... ... Q_IMPORT_PLUGIN(PlottingPlugin) int main(int argc, char *argv[]) { ... ... }
All compiles and linkes fine, but the ctor of PlottingPlugin (as the PlottingPlugin::registerTypes()) does not called at all.
To call it I use a workaround to call it explicitly from my main function:
int main(...) { qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_PlottingPlugin().instance())->registerTypes("com.my.plotting"); ... ... }
I looked on generated metadata of my plugin static library and I see that all info (URI and etc are present there):
== plotlib.moc ===
... ... QT_PLUGIN_METADATA_SECTION static const unsigned char qt_pluginMetaData[] = { 'Q', 'T', 'M', 'E', 'T', 'A', 'D', 'A', 'T', 'A', ' ', ' ', 'q', 'b', 'j', 's', 0x01, 0x00, 0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x13, 0x03, 0x00, 0x00, 0x03, 0x00, 'I', 'I', 'D', 0x00, 0x00, 0x00, ',', 0x00, 0x00, 0x00, 'o', 0x00, 'r', 0x00, 'g', 0x00, '.', 0x00, 'q', 0x00, 't', 0x00, '-', 0x00, 'p', 0x00, 'r', 0x00, 'o', 0x00, 'j', 0x00, 'e', 0x00, 'c', 0x00, 't', 0x00, '.', 0x00, 'Q', 0x00, 't', 0x00, '.', 0x00, 'Q', 0x00, 'Q', 0x00, 'm', 0x00, 'l', 0x00, 'E', 0x00, 'x', 0x00, 't', 0x00, 'e', 0x00, 'n', 0x00, 's', 0x00, 'i', 0x00, 'o', 0x00, 'n', 0x00, 'I', 0x00, 'n', 0x00, 't', 0x00, 'e', 0x00, 'r', 0x00, 'f', 0x00, 'a', 0x00, 'c', 0x00, 'e', 0x00, '/', 0x00, '1', 0x00, '.', 0x00, '0', 0x00, 0x9b, 0x10, 0x00, 0x00, 0x09, 0x00, 'c', 'l', 'a', 's', 's', 'N', 'a', 'm', 'e', 0x00, 0x0e, 0x00, 'P', 'l', 'o', 't', 't', 'i', 'n', 'g', 'P', 'l', 'u', 'g', 'i', 'n', 'Z', '`', 0xa1, 0x00, 0x07, 0x00, 'v', 'e', 'r', 's', 'i', 'o', 'n', 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x05, 0x00, 'd', 'e', 'b', 'u', 'g', 0x00, 0x15, 0x18, 0x00, 0x00, 0x08, 0x00, 'M', 'e', 't', 'a', 'D', 'a', 't', 'a', 0x00, 0x00, '@', 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, '<', 0x00, 0x00, 0x00, 0x14, 0x03, 0x00, 0x00, 0x03, 0x00, 'u', 'r', 'i', 0x00, 0x00, 0x00, '$', 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, ' ', 0x00, 0x00, 0x00, 0x0f, 0x00, 'c', 'o', 'm', '.', 'm', 'y', '.', 'p', 'l', 'o', 't', 't', 'i', 'n', 'g', 0x00, 0x00, 0x00, 0x8b, 0x01, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 't', 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00 }; ... ...
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-74775 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
257579,4 | moc: Add a standard way of specifying a URI as part of Q_PLUGIN_METADATA | dev | qt/qtbase | Status: MERGED | -2 | 0 |
258614,1 | Use moc's "URI" parameter to Q_PLUGIN_METADATA | dev | qt/qtdeclarative | Status: DEFERRED | 0 | 0 |