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. Loading my first newly built plugin while debugging
Forum Updated to NodeBB v4.3 + New Features

Loading my first newly built plugin while debugging

Scheduled Pinned Locked Moved Solved General and Desktop
12 Posts 3 Posters 2.9k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi,

    You should set the QT_DEBUG_PLUGINS environnement variable to 1 and re-run your application. You’ll get more information about what is happening.

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

    M 1 Reply Last reply
    0
    • SGaistS SGaist

      Hi,

      You should set the QT_DEBUG_PLUGINS environnement variable to 1 and re-run your application. You’ll get more information about what is happening.

      M Offline
      M Offline
      mgreenish
      wrote on last edited by
      #3

      @SGaist said in Loading my first newly built plugin while debugging:

      QT_DEBUG_PLUGINS

      Great! Now I get a message in the Application Output:

      QMachOParser: '/Users/greanie/Work/HapticX/Engineering/Software/plugins/libreactionsserverplugin_debug.dylib' is not a Qt plugin
      

      So somehow my plugin is not properly set up.

      Below is my .pro file:

      TEMPLATE        = lib                                       # making a library, not an executible
      CONFIG         += plugin                                    #
      QT             += widgets network gui
      INCLUDEPATH    += ../vibecreator/vibecreator/               # include path to plugin interface
      TARGET          = $$qtLibraryTarget(reactionsserverplugin)  # name of the library file in which the plugin will be stored, should be same as name of the plugin
      DESTDIR         = ../plugins
      
      # install
      target.path = ../plugins
      INSTALLS += target
      
      CONFIG += install_ok  # Do not cargo-cult this!
      
      SOURCES += reactionsserverplugin.cpp
      
      HEADERS  += reactionsserverplugin.h
      
      FORMS += \
          reactionfileform.ui
      
      DISTFILES += \
          reactionsserver.plugin.json
      

      Below is my plugin header:

      #include <QObject>
      #include <QWidget>
      #include <QtPlugin>
      #include <QDialog>
      
      //#include "../vibecreator/vibecreator/reactionsserverinterface.h"
      #include "reactionsserverinterface.h"
      #include "creatorwindow.h"
      
      namespace Ui {
          class ReactionServerFileForm;
      }
      
      class ReactionsServerPlugin : public QWidget, ReactionsServerInterface
      {
          Q_OBJECT
          Q_PLUGIN_METADATA( IID "org.qt-project.Qt.AddHaptics.ReactionsServerInterface" FILE "reactionsserver.plugin.json" )
          Q_INTERFACES(ReactionsServerInterface)
      
      public:
          ReactionsServerPlugin( CreatorWindow* parent ) { setParent( parent ); } // makes this qwidget a child window
      
          void createForm();  // override;
          void showForm();    // override
          void hideForm();
      
      private:
          Ui::ReactionServerFileForm* ui;
      
      };
      
      #endif // REACTIONSSERVER_GLOBAL_H
      

      Below is my source:

      #include <QtWidgets>
      
      #include "reactionsserverplugin.h"
      #include "ui_reactionfileform.h"
      
      void ReactionsServerPlugin::createForm()
      {
          ui = new Ui::ReactionServerFileForm;
          ui->setupUi(this);
      }
      
      void ReactionsServerPlugin::showForm() {
          this->setVisible(true);
      }
      
      void ReactionsServerPlugin::hideForm() {
          this->setVisible(false);
      }
      

      It all compiles, as per the dylib file. Any ideas on what I might be doing wrong?

      1 Reply Last reply
      0
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by mrjj
        #4

        Hi
        For the ReactionsServerInterface
        Do you have something like
        Q_DECLARE_INTERFACE(ReactionsServerInterface, "in.forwardbias.tool/1.0")
        under the class definition ?

        M 1 Reply Last reply
        1
        • mrjjM mrjj

          Hi
          For the ReactionsServerInterface
          Do you have something like
          Q_DECLARE_INTERFACE(ReactionsServerInterface, "in.forwardbias.tool/1.0")
          under the class definition ?

          M Offline
          M Offline
          mgreenish
          wrote on last edited by
          #5

          @mrjj I didn't put my interface class in my past post because I figured my problem was a set up one with the plugin. But, here it is

          #ifndef REACTIONSSERVER_INTERFACE_H
          #define REACTIONSSERVER_INTERFACE_H
          
          class ReactionsServerInterface
          {
          
          public:
              virtual ~ReactionsServerInterface(){}
              virtual void createForm() = 0;
              virtual void showForm() = 0;
              virtual void hideForm() = 0;
          };
          
          #define ReactinonsSeverInterface_iid "org.qt-project.Qt.AddHaptics.ReactionsServerInterface"
          
          Q_DECLARE_INTERFACE(ReactionsServerInterface, ReactinonsSeverInterface_iid)
          
          #endif // REACTIONSSERVER_H
          
          I do have the Q_DECLARE_INTERFACE .
          

          The only thing I can find that is wrong in my plugin is that I get a warning that reactionsserver.plugin.json doesn't hold a valid json object. But I don't know how that would influence whether or not my plugin is a valid plugin.

          mrjjM 1 Reply Last reply
          0
          • M mgreenish

            @mrjj I didn't put my interface class in my past post because I figured my problem was a set up one with the plugin. But, here it is

            #ifndef REACTIONSSERVER_INTERFACE_H
            #define REACTIONSSERVER_INTERFACE_H
            
            class ReactionsServerInterface
            {
            
            public:
                virtual ~ReactionsServerInterface(){}
                virtual void createForm() = 0;
                virtual void showForm() = 0;
                virtual void hideForm() = 0;
            };
            
            #define ReactinonsSeverInterface_iid "org.qt-project.Qt.AddHaptics.ReactionsServerInterface"
            
            Q_DECLARE_INTERFACE(ReactionsServerInterface, ReactinonsSeverInterface_iid)
            
            #endif // REACTIONSSERVER_H
            
            I do have the Q_DECLARE_INTERFACE .
            

            The only thing I can find that is wrong in my plugin is that I get a warning that reactionsserver.plugin.json doesn't hold a valid json object. But I don't know how that would influence whether or not my plugin is a valid plugin.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by
            #6

            @mgreenish
            I also got that message as far as i can recall but it still loaded.

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

              Can you show the json ?

              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
              0
              • M Offline
                M Offline
                mgreenish
                wrote on last edited by mgreenish
                #8

                I read in a post that it could be left blank, so that gave me an error that cased the compiler to error out. So I found this online and now I only get a warning:

                @{ "Keys": [ "reactionserveristhisplugin" ] }@
                

                Granted, I haven't figured out what is wrong with this structure as I didn't think this would be source of my error.

                The warning is:

                ../reactionsserverplugin.h:20: Warning: Plugin Metadata file "reactionsserver.plugin.json" does not contain a valid JSON object. Declaration will be ignored
                
                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  Might be silly but I wonder if it's because you have two dots in your file name.

                  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
                  0
                  • M Offline
                    M Offline
                    mgreenish
                    wrote on last edited by
                    #10

                    That doesn't seem to be it:

                    ../reactionsserverplugin.h:20: Warning: Plugin Metadata file "reactionsserverplugin.json" does not contain a valid JSON object. Declaration will be ignored
                    
                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      Again might be silly but did you try to lint your json file ? Might have a stray char somewhere that's messing things up.

                      {
                          "Keys": ["reactionserveristhisplugin"]
                      }
                      

                      Should be good.

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

                      M 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Again might be silly but did you try to lint your json file ? Might have a stray char somewhere that's messing things up.

                        {
                            "Keys": ["reactionserveristhisplugin"]
                        }
                        

                        Should be good.

                        M Offline
                        M Offline
                        mgreenish
                        wrote on last edited by
                        #12

                        @SGaist So it turns out that this file is optional. I removed it from the Q_PLUGIN_METADATA declaration and that seemed to resolve the warning. Now everything compiles and the dylib loads.

                        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