The way I would do that is:
void Dialog::slotBtn(void)
{
// MyThread *myt; // declared in the class - on stack
myt = new MyThread;
connect( myt, SIGNAL(finished()), this, SLOT(mytFinishedSlot()));
button->setEnabled(false); //to prevent running again the same thread
myt->start();
}
void Dialog::mytFinishedSlot(){
//retrieve the data from the thread
disconnect( myt, SIGNAL(finished()), this, SLOT(mytFinishedSlot()));
delete myt;
button->setEnabled(true); //"turn one" button
}
void Dialog::slotBtn(void)
{
// MyThread *myt; // declared in the class - on stack
myt = new MyThread;
connect( myt, SIGNAL(finished()), this, SLOT(mytFinishedSlot()));
button->setEnabled(false); //to prevent running again the same thread
myt->start();
}
void Dialog::mytFinishedSlot(){
//retrieve the data from the thread
disconnect( myt, SIGNAL(finished()), this, SLOT(mytFinishedSlot()));
delete myt;
button->setEnabled(true); //"turn one" button
}
To copy to clipboard, switch view to plain text mode
Comments and critique are more then welcome.
Bookmarks