is it possible to use QT qmake instructions in defines?
I tried to create an QT Plugin Interface class by a define:
#define PLUGIN(NAME) \
class NAME ## Plugin : public QObject, public IPluginInterface \
{ \
Q_OBJECT \
Q_PLUGIN_METADATA(IID "org.my.Plugins" FILE "NAME ## .json") \
Q_INTERFACES(IPluginInterface) \
public: \
virtual ~NAME ## PluginInterface(){} \
NAME ## PluginInterface(){} \
/* implementation of interface */
}; \
NAME ## Plugin NAME ## plugininterface;
but after running qmake and make my program does not load the plugin. Message is: Plugin verification data mismatch
No, it's not (directly) possible, as moc
does not do preprocessing. See the relevant section in the Qt docs for moc
.
You might get away with it if you run the preprocessor manually (with some hacking not to expand moc
-used macros like Q_OBJECT
) and then run moc
on the preprocessed file. But that would require significnat support in your buildsystem.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.