PDA

View Full Version : how to call signal from GUI to dll with the same object



praveenhi5
9th November 2020, 06:44
In mainwindow constructor i am creating the member variable
kkkk= new Exp_IRIG_EMIT;

i am connecting the signal for updating progressbar range and value

calling initialize function to create thread in dll. and it will be loop
kkkk->Initialize();


click on ABORT push button on_pushButton_clicked() function get called

In side function i am calling signal to abort the thread

if i use kkkk object to abort its not calling abort signal

signal is get called when i create a new object with Exp_IRIG_EMIT.

i want to use the same object how to abort. any one can help to sortout the issue.

d_stranz
9th November 2020, 15:55
There are (at least) four errors in your code:

1 - The while(1) loop in ReadFunction() never allows the thread's event loop to run and process any events (such as calls to the abort slot). Therefore, the call to the slot will never have a chance to be processed and fAbort will never change status.

2 - In your MainWindow on_pushButton_clicked method, you are creating a second instance of Exp_IRIG_EMIT. This is not the same instance as the one you created (kkkk) in the constructor. You should know this - it is basic C++. So connecting a signal and slot together from this new instance does nothing.

3 - In your MainWindow constructor, you create an instance of Exp_IRIG_EMIT (kkkk), but you never connect the pushbutton's clicked() signal to its abort slot.

4 - You do not need an SAbortSignal in MainWIndow if all you want to do is call the Abort_Thread slot in Exp_IRIG_EMIT. Simply connect QPushButton::clicked() directly to kkkk's slot in the MainWindow constructor.