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. Plugin with signals and slots [SOLVED]

Plugin with signals and slots [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
pluginsignalslots
7 Posts 3 Posters 7.3k 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
    dnasta
    wrote on 7 Sept 2015, 18:55 last edited by dnasta 9 Sept 2015, 16:51
    #1

    Hello good afternoon,

    A plugin can have signals and slots that are caught and emited by the application that load?

    I find no documentation or example,

    Thank you,

    Cheers,

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 8 Sept 2015, 11:03 last edited by
      #2

      Hi
      As far as I know, its possible.

      I found a sample here
      http://www.qtcentre.org/archive/index.php/t-56135.html

      look for "The following code builds plugin lib "
      ca. middle of page.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dnasta
        wrote on 9 Sept 2015, 04:06 last edited by dnasta 9 Sept 2015, 04:47
        #3

        Hello mrjj,

        thanks for the reply,

        my plugin implementation is somewhat different, that's why when I add Q_OBJECT the interface, not compiled dll (unresolved external symbol)

        this is the implementation with Q_OBJECT

        class PluginPruebaInterfaz : public QObject
        {
            Q_OBJECT
        public:
            virtual ~PluginPruebaInterfaz() {}
        
            virtual QString retornaCadenaInvertida(QString cadena) = 0;
        signals:
            void senial(QString cadena);
        };
        
        class PluginPrueba : public PluginPruebaInterfaz,
                             public OtroPluginInterfaz,
                             public TercerPluginInterfaz
        {
            Q_OBJECT
            Q_PLUGIN_METADATA(IID "xxx.PluginPruebaInterfaz")
            Q_INTERFACES(PluginPruebaInterfaz OtroPluginInterfaz TercerPluginInterfaz)
        
            ClasePluginPrueba   *plgPrueba;
            ClaseOtroPlugin     *plgOtro;
            ClaseTercerPlugin   *plgTercero;
        
        public:
        
            PluginPrueba();
            ~PluginPrueba();
        
            QString retornaCadenaInvertida(QString cadena);
        
            bool retornaNegacion(bool valor);
        
            qint64 retornaNegativoPositivo(qint64 valor);
        };
        

        this implementation is that works

        class PluginPruebaInterfaz
        {
        public:
            virtual ~PluginPruebaInterfaz() {}
        
            virtual QString retornaCadenaInvertida(QString cadena) = 0;
        };
        
        class PluginPrueba : public QObject,
                             public PluginPruebaInterfaz,
                             public OtroPluginInterfaz,
                             public TercerPluginInterfaz
        {
            Q_OBJECT
            Q_PLUGIN_METADATA(IID "xxx.PluginPruebaInterfaz")
            Q_INTERFACES(PluginPruebaInterfaz OtroPluginInterfaz TercerPluginInterfaz)
        
            ClasePluginPrueba   *plgPrueba;
            ClaseOtroPlugin     *plgOtro;
            ClaseTercerPlugin   *plgTercero;
        
        public:
        
            PluginPrueba();
            ~PluginPrueba();
        
            QString retornaCadenaInvertida(QString cadena);
        
            bool retornaNegacion(bool valor);
        
            qint64 retornaNegativoPositivo(qint64 valor);
        };
        

        Thank you,

        Greetings,

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dnasta
          wrote on 9 Sept 2015, 04:58 last edited by
          #4

          I found this post and I could implement a signal emitted from the dll

          I declared in the interface virtual QObject * getObject () = 0; for the QObject that requires connect

          In the implementation, I added

          QObject* getObject() { return this; }
          	
          signals:
              void senial(QString cadena);
          

          And I connected with

          connect(
                              plgItfz->getObject(),
                              SIGNAL(senial(QString)),
                              this,
                              SLOT(senialRecibida(QString))
                              );
          

          the next step is send a signal from the application and receive the plugin

          Thank you,

          Greetings,

          1 Reply Last reply
          2
          • M Offline
            M Offline
            mrjj
            Lifetime Qt Champion
            wrote on 9 Sept 2015, 06:19 last edited by
            #5

            super,
            thank you for updating.

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dnasta
              wrote on 9 Sept 2015, 16:50 last edited by
              #6

              Hello good afternoon,

              When I go to the forum to solve a problem it is because I could not find anything on the web, but in this case was too simple theme, perhaps only experiencing what he had resolved because it is too simple to implement signals and slots between the application and the dll

              To end the post: to implement the slot in the plug receiving a signal from the application, add the virtual interface slot

              public slots:
              
                  virtual void disparador(QString texto) = 0;
              

              and I made in the implementation of the interface

              public slots:
              
                  void disparador(QString texto);
              

              to connect to the application, I used getObject

              connect(
                                  this,
                                  SIGNAL(disparaTexto(QString)),
                                  plgItfz->getObject(),
                                  SLOT(disparador(QString))
                                  );
              

              Thank you

              greetings

              Y 1 Reply Last reply 14 Jun 2023, 13:07
              2
              • D dnasta
                9 Sept 2015, 16:50

                Hello good afternoon,

                When I go to the forum to solve a problem it is because I could not find anything on the web, but in this case was too simple theme, perhaps only experiencing what he had resolved because it is too simple to implement signals and slots between the application and the dll

                To end the post: to implement the slot in the plug receiving a signal from the application, add the virtual interface slot

                public slots:
                
                    virtual void disparador(QString texto) = 0;
                

                and I made in the implementation of the interface

                public slots:
                
                    void disparador(QString texto);
                

                to connect to the application, I used getObject

                connect(
                                    this,
                                    SIGNAL(disparaTexto(QString)),
                                    plgItfz->getObject(),
                                    SLOT(disparador(QString))
                                    );
                

                Thank you

                greetings

                Y Offline
                Y Offline
                YTKOHOC
                wrote on 14 Jun 2023, 13:07 last edited by
                #7

                @dnasta I have found simple example with similar implementation.
                But anyway, this is old school syntax of connect, with new syntax it doesn't work.

                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