Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Getting error in Q_PLUGIN_METADATA when using macro
Forum Updated to NodeBB v4.3 + New Features

Getting error in Q_PLUGIN_METADATA when using macro

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 611 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    nathanday89
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved