Problem in implementing signal slot in a threaded dll application



  • 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



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



  • 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.



  • 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.



  • 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 :(



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



  • 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.



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



  • 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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.