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. Problem in implementing signal slot in a threaded dll application
Forum Updated to NodeBB v4.3 + New Features

Problem in implementing signal slot in a threaded dll application

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 5.2k Views 1 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.
  • A Offline
    A Offline
    aashish.lg
    wrote on last edited by
    #1

    Hi,

    I wote a dll using qt which will be loaded by mstsc process in windows and by XRDP process in Linux machine.
    After getting loaded by process my dll class will launch a qt thread which will be receiving data from server using QTcpSocket.
    based on some special data , it will emit some signal to the calling class. I have done this in windows OS , but same source code is not getting slots to be get called by emitting singlas from therads.

    I have defined one global QAplication object.
    In my application readyread signals, coonected , disconnected, this kind of sdtandards qt signals are coming but only user defined signals are not calling slots. It means I suspect that the qt application event loop is working .

    Please help.

    Any help will be greatly appriciated.

    Regards

    Ashish

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      If you run in a debugger, do you get any output on the console indicating problems in setting up the connections?

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aashish.lg
        wrote on last edited by
        #3

        No I don't get any output in debugger. One more thing I would like to highlight here is that I am not calling QApplication exec method , when I tried to do it from separate thread(to avoid full dll hanging), it says QAplication::Exec() should be called from main thread.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          aashish.lg
          wrote on last edited by
          #4

          I tried to emit signals from the class which launch thread, it is calling slots in the same class properly. But from different thread I am not able to get slot invoked. My class which invokes the thread is derived from QObject.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aashish.lg
            wrote on last edited by
            #5

            Amazingly I am not even able to use Qtimer in my class, it is not generating timeout() signals.

            Earlier I thought of that I will call a method on data arrival from my thread and in that method I can start a 1 msec timer and can do my work when timer event fired. Unfortunately this itself is not working :(

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              For queued signals/slots to work you must be running an event loop in the main thread (best using the QApplication/QCoreApplication object).

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • A Offline
                A Offline
                aashish.lg
                wrote on last edited by
                #7

                Thats what the main problem is , my application is a Qt library that is getting loaded by some 3rd party exe, so I dont have main thread , so how to start qt application event loop.

                I googled a lot but not getting any way to get rid of this problem.
                Is it really possible to write a qt dll that is used by some 3rd party application.
                If this is true then please advice any workaround to get rid of this prob.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on last edited by
                  #8

                  Sorry, I don't know whether/how this is achievable, I never ran into such a setup. Maybe someone else has more experience here.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    aashish.lg
                    wrote on last edited by
                    #9

                    Hi folkz,

                    After long analysis and trying multiple approaches , I came to conclusion that qt dll can only be utilized just to avail the functionality of some of the qt core classes so that we can ship this dll in a platform independent manner.
                    But whenever we wanted to achieve some UI related stuff then it is not good idea to have a qt dll because behaviour would be unexpected on different plattform.

                    So in the scenarios mentioned above where we dont have main thread of third party application, we have to launch a separate process and from there we should do our rest of the qt stuff.. It will simply rock!!!!!!!!!!!
                    I have achieved my functionality like this only.

                    Regards
                    Ashish

                    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