path: root/src/tools/moc/moc.cpp
diff options
authorUlf Hermann <>2019-03-29 16:05:25 +0100
committerUlf Hermann <>2019-04-11 14:43:27 +0000
commite7e557cea2f35031cf3a51fcb8fa7a275625830f (patch)
treeb30ad3c6fa6e9ddc084e82c00d2cca1dd108ee18 /src/tools/moc/moc.cpp
parent217f3d83d74507e40ee5a6f43b026bb440515d6e (diff)
moc: Add a standard way of specifying a URI as part of Q_PLUGIN_METADATA
Usually, when you load a plugin, you don't want to load just any plugin that fulfills a given interface, but rather a specific one. When loading dynamic plugins you can differentiate the plugins by file name. This doesn't work in the static case, and file names are also separate from the plugin metadata shipped inside the plugin files. To solve this problem, different hacks have been developed in various places. QML extension plugins add a special property "uri" via the -M option of moc, QML debug plugins expect you to add a json file with an array of "Keys", Qt Creator plugins have a "Name" in their json files, etc. By allowing the identifier for the plugin to be specified inline with the metadata declaration we can make many of the above workarounds obsolete and provide a clean way for users to find their plugins. Task-number: QTBUG-74775 Change-Id: Ie2af16c49d4c5aa5a77fab0fae1e0a4449bd7a39 Reviewed-by: Olivier Goffart (Woboq GmbH) <>
Diffstat (limited to 'src/tools/moc/moc.cpp')
1 files changed, 4 insertions, 0 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index 2f52dd6ca0..7f43917f7e 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -1311,6 +1311,9 @@ void Moc::parsePluginData(ClassDef *def)
if (l == "IID") {
def->pluginData.iid = unquotedLexem();
+ } else if (l == "URI") {
+ def->pluginData.uri = unquotedLexem();
} else if (l == "FILE") {
QByteArray metaDataFile = unquotedLexem();
@@ -1351,6 +1354,7 @@ void Moc::parsePluginData(ClassDef *def)
+ " does not contain a valid JSON object. Declaration will be ignored";
def->pluginData.iid = QByteArray();
+ def->pluginData.uri = QByteArray();