Getting error in Q_PLUGIN_METADATA when using macro
Unsolved
General and Desktop
-
I want to use the variable PLUGINJSON in my header file as an input to
Q_PLUGIN_METADATA(IID "test.plugin" FILE PLUGINJSON)However, I am getting the error "../pluginTemplate/plugin.h:22: Parse error at "FILE"" when I build my project
This is my part of my.pro file.
QT += widgets PLUGIN_NAME = "PluginA" DEFINES = PLUGIN_NAME TEMPLATE = lib INCLUDEPATH += /home/nathan/Documents/Projects/QtTestPrograms/pluginManagerTest CONFIG += c++11 CONFIG += plugin TARGET = $$qtLibraryTarget($$PLUGIN_NAME) DEFINES += QT_DEPRECATED_WARNINGS # Builds a .json file from .pro variables PLUGINJSON = $$_PRO_FILE_PWD_/$${TARGET}.json DEFINES = PLUGINJSON
This is my header file:
#ifndef PLUGIN_H #define PLUGIN_H #include "plugin_global.h" #include <QWidget> #include <interfaces.h> namespace Ui { class Plugin; } class PLUGIN_EXPORT Plugin : public QWidget, public IntergerInterface, public FloatInterface, public StringInterface, public WidgetInterface { Q_OBJECT Q_PLUGIN_METADATA(IID "test.plugin.plugin" FILE PLUGINJSON) Q_INTERFACES(IntergerInterface FloatInterface StringInterface WidgetInterface) public: explicit Plugin(QWidget* parent = nullptr); // ~Plugin(); private: Ui::Plugin* ui; float getFloat() override; int getInterger() override; QString getString() override; QWidget* getWidget() override; }; #endif // PLUGIN_H
Can I use a macro like this in Q_PLUGIN_METADATA? If so, how can I do it correctly. I want to use the macro so users don't have to change the plugin name in more than one place.
-
Hi,
Check the build panel to see the command invocation.
One thing for sure is that your DEFINES line is wrong, first thing your are emptying the original content of the variable and your literally put PLUGINJSON in it and not the content of that variable.