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. how to send a signal from the DLL library implemented to the application (.exe)
Forum Updated to NodeBB v4.3 + New Features

how to send a signal from the DLL library implemented to the application (.exe)

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 6 Posters 3.1k Views 3 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.
  • D Offline
    D Offline
    Domenico
    wrote on last edited by
    #9

    @Pablo-J-Rogina
    just modified. thanks. what's wrong with the code?

    G 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #10

      @Domenico said in how to send a signal from the DLL library implemented to the application (.exe):

      what's wrong with the code?

      You neither instantiate ApplicationGui nor you run the main event loop.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      D 1 Reply Last reply
      3
      • D Domenico

        @Pablo-J-Rogina
        just modified. thanks. what's wrong with the code?

        G Offline
        G Offline
        Gerd
        wrote on last edited by
        #11

        @Domenico
        you do connect after send.
        just revert the order of lib.send()
        and
        QObject::connect

        D 1 Reply Last reply
        4
        • Christian EhrlicherC Christian Ehrlicher

          @Domenico said in how to send a signal from the DLL library implemented to the application (.exe):

          what's wrong with the code?

          You neither instantiate ApplicationGui nor you run the main event loop.

          D Offline
          D Offline
          Domenico
          wrote on last edited by
          #12

          @Christian-Ehrlicher said in how to send a signal from the DLL library implemented to the application (.exe):

          You neither instantiate ApplicationGui nor you run the main event loop

          sorry for ignorance what do we mean by not creating an instance nor running the main cycle of events? can you give me an example

          1 Reply Last reply
          0
          • G Gerd

            @Domenico
            you do connect after send.
            just revert the order of lib.send()
            and
            QObject::connect

            D Offline
            D Offline
            Domenico
            wrote on last edited by
            #13

            @Gerd

            I tried to tidy up

            QObject::connect(...)
            
            lib.send();
            

            and it's wrong ... if that's what you mean

            1 Reply Last reply
            0
            • Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #14

              @Domenico said in how to send a signal from the DLL library implemented to the application (.exe):

              can you give me an example

              When you take a look at your main() you will see that you don't call QApplication::exec() and simply return - so what should happen?

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              D 1 Reply Last reply
              2
              • Christian EhrlicherC Christian Ehrlicher

                @Domenico said in how to send a signal from the DLL library implemented to the application (.exe):

                can you give me an example

                When you take a look at your main() you will see that you don't call QApplication::exec() and simply return - so what should happen?

                D Offline
                D Offline
                Domenico
                wrote on last edited by
                #15

                @Christian-Ehrlicher

                so there is no need for this instance

                #include <QtCore/QCoreApplication>
                #include "MyLib .h"
                int main( int argc, char *argv[ ] )
                {
                    QCoreApplication a(argc,argv);
                   MyLib lib;
                
                 return true;
                }
                

                and would be fine even without main or:

                #include <QtCore/QCoreApplication>
                #include "MyLib .h"
                int main( int argc, char *argv[ ] )
                {
                    QCoreApplication a(argc,argv);
                 return a.exec();
                }
                

                quite right?

                mrjjM 1 Reply Last reply
                0
                • D Domenico

                  @Christian-Ehrlicher

                  so there is no need for this instance

                  #include <QtCore/QCoreApplication>
                  #include "MyLib .h"
                  int main( int argc, char *argv[ ] )
                  {
                      QCoreApplication a(argc,argv);
                     MyLib lib;
                  
                   return true;
                  }
                  

                  and would be fine even without main or:

                  #include <QtCore/QCoreApplication>
                  #include "MyLib .h"
                  int main( int argc, char *argv[ ] )
                  {
                      QCoreApplication a(argc,argv);
                   return a.exec();
                  }
                  

                  quite right?

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

                  @Domenico
                  Hi
                  Yes that should do it.

                  However

                    lib.send();  // emits signal.
                   QObject::connect(&lib,&lib::sendSignal,this,&ApplicationGui::slotSignal); // then connect to signal ?
                  

                  That would not trigger ApplicationGui::slotSignal
                  unless you call
                  lib.send();
                  again.

                  D 1 Reply Last reply
                  3
                  • mrjjM mrjj

                    @Domenico
                    Hi
                    Yes that should do it.

                    However

                      lib.send();  // emits signal.
                     QObject::connect(&lib,&lib::sendSignal,this,&ApplicationGui::slotSignal); // then connect to signal ?
                    

                    That would not trigger ApplicationGui::slotSignal
                    unless you call
                    lib.send();
                    again.

                    D Offline
                    D Offline
                    Domenico
                    wrote on last edited by
                    #17

                    thank you all. I solved the problem. the problem is that I made calls after having exported the function from the library DLL that is with:

                    extern "C" __declspec(dllexport) void send();
                    

                    I imagine this way it is not connected between dlls and application gui for the use of the signal/slot.
                    therefore to make the use of the signal / slot work, it is sufficient to make function calls to the dll library with an instance:

                    MyLib lib;
                    lib.send();
                    ...
                    

                    thank you!

                    Pablo J. RoginaP 1 Reply Last reply
                    0
                    • D Domenico

                      thank you all. I solved the problem. the problem is that I made calls after having exported the function from the library DLL that is with:

                      extern "C" __declspec(dllexport) void send();
                      

                      I imagine this way it is not connected between dlls and application gui for the use of the signal/slot.
                      therefore to make the use of the signal / slot work, it is sufficient to make function calls to the dll library with an instance:

                      MyLib lib;
                      lib.send();
                      ...
                      

                      thank you!

                      Pablo J. RoginaP Offline
                      Pablo J. RoginaP Offline
                      Pablo J. Rogina
                      wrote on last edited by
                      #18

                      @Domenico said in how to send a signal from the DLL library implemented to the application (.exe):

                      I solved the problem.

                      so please don't forget to mark your post as such!

                      Upvote the answer(s) that helped you solve the issue
                      Use "Topic Tools" button to mark your post as Solved
                      Add screenshots via postimage.org
                      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                      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