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. Problems loading plugins
Forum Updated to NodeBB v4.3 + New Features

Problems loading plugins

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 299 Views
  • 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.
  • D Offline
    D Offline
    django.Reinhard
    wrote on last edited by
    #1

    Hi,

    I have several plugins that are subclasses of an abstract class. Interface class exists and is declared in abstract base class.
    Plugin_Metadata macro is used in the final plugin class.

    I followed plug_and_paint example with the difference, that I have an abstract class between interface and plugin.

    Building succeeds without errors, but when I run the app, no plugin is loaded.

    Debugging the app shows some error message like:

    undefined symbol: _ZNK20AbstractCenterWidget10metaObjectEv)"
    

    which is the abstract class, where I declared the interface-usage.

    Following the error, I added the plugin_metadata macro to the abstract class as well, but now compilation fails as moc tries to create an instance from that abstract class, which of cause will fail.

    How can I break that tangle?

    A 1 Reply Last reply
    0
    • D django.Reinhard

      Hi,

      I have several plugins that are subclasses of an abstract class. Interface class exists and is declared in abstract base class.
      Plugin_Metadata macro is used in the final plugin class.

      I followed plug_and_paint example with the difference, that I have an abstract class between interface and plugin.

      Building succeeds without errors, but when I run the app, no plugin is loaded.

      Debugging the app shows some error message like:

      undefined symbol: _ZNK20AbstractCenterWidget10metaObjectEv)"
      

      which is the abstract class, where I declared the interface-usage.

      Following the error, I added the plugin_metadata macro to the abstract class as well, but now compilation fails as moc tries to create an instance from that abstract class, which of cause will fail.

      How can I break that tangle?

      A Offline
      A Offline
      aliks-os
      wrote on last edited by aliks-os
      #2

      @django-Reinhard Too hard say something without your code. Please show declaration of your class and how you load plugin and create instance of your object

      1 Reply Last reply
      0
      • D Offline
        D Offline
        django.Reinhard
        wrote on last edited by
        #3

        Well, here we go:

        first the interface:

        #include <QtPlugin>
        
        QT_BEGIN_NAMESPACE
        class QWidget;
        class QCloseEvent;
        class QShowEvent;
        QT_END_NAMESPACE
        
        
        class PluginPageInterface
        {
        public:
          virtual ~PluginPageInterface() = default;
        
          virtual void closeEvent(QCloseEvent* e) = 0;
          virtual void showEvent(QShowEvent* e) = 0;
        
          virtual QWidget* createContent() = 0;
          virtual void connectSignals() = 0;
          virtual void updateStyles()   = 0;
          };
        
        QT_BEGIN_NAMESPACE
        #define PluginPageInterface_iid "de.schwarzrot.FalconView.PluginPage/0.1"
        Q_DECLARE_INTERFACE(PluginPageInterface, PluginPageInterface_iid)
        QT_END_NAMESPACE
        

        the abstract class declaration:

        #include <QWidget>
        #include <PluginPageInterface.h>
        
        QT_BEGIN_NAMESPACE
        class CenterView;
        class SettingsNotebook;
        class QString;
        class QAction;
        class QFile;
        QT_END_NAMESPACE
        
        
        /*! loads widgets from uiFile and allows late initialization at page usage
         */
        class AbstractCenterWidget : public QWidget, public PluginPageInterface
        {
          Q_OBJECT
          Q_INTERFACES(PluginPageInterface)
        public:
          void     initialize(const QString& fileName, const QString& name, bool addScrollArea = false);
          QAction* viewAction();
        
          // called by central widget stack
          virtual void closeEvent(QCloseEvent* e) override;
          virtual void showEvent(QShowEvent* e) override;
        
        signals:
          void dataChanged(AbstractCenterWidget* w, const QVariant& changed);
        
        protected:
          explicit AbstractCenterWidget(QWidget* parent = nullptr);
          virtual ~AbstractCenterWidget() = default;
        
          virtual QWidget* createContent();
        
        private:
          QAction*     vAction;
          QString      fileName;
          bool         addScrollArea;
          };
        

        ... and here one plugin declaration:

        #include <abscenterwidget.h>
        #include <PluginPageInterface.h>
        
        QT_BEGIN_NAMESPACE
        class FixtureEdit;
        class AxisMask;
        QT_END_NAMESPACE
        
        
        class FixtureManager : public AbstractCenterWidget
        {
          Q_OBJECT
          Q_PLUGIN_METADATA(IID "PluginPageInterface_iid" FILE "fixtureManager.json")
        public:
          FixtureManager(QWidget* parent = nullptr);
        
          virtual void connectSignals() override;
          virtual void updateStyles()   override;
          void activateEditor(int index);
        
        protected:
          virtual void keyPressEvent(QKeyEvent* event) override;
          virtual void showEvent(QShowEvent *event) override;
          virtual QWidget* createContent() override;
        
        private:
          QWidget*  client;
          QFont     cFonts[4];
          QString   cStyle[4];
          AxisMask* axisMask;
          };
        
        1 Reply Last reply
        0
        • D Offline
          D Offline
          django.Reinhard
          wrote on last edited by
          #4

          I got it.

          Just as a dumb test I copied the plugin from plugandpaint sample into plugindir of my app and that got loaded.

          This showed me that the loader failures had nothing to do with my programming, but that there was a problem with the plugin files.

          So I investigated further in that direction and found out that no link errors are output at building the plugins. So if you think everything is error free, that is far from true for the plugins.

          Was then still a tough piece of work, but in the meantime all plugins get loaded.

          1 Reply Last reply
          0

          • Login

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