-1

EDIT: I do not want to call the object destructor as suggested in this thread.

I have connected a button to a slot. This slot starts a process.

ui->btnActivate->setText("Start");
connect(ui->btnActivate, SIGNAL(clicked()),this, SLOT(startProcess()));

After the process finishes, I do

ui->btnActivate->setText("Close");
connect(ui->btnActivate, SIGNAL(clicked()),this, SLOT(close()));

But now the button starts the process and then run close. How can I disconnect the first connection before altering the buttons behaviour? I would like to avoid calling the Destructor

Community
  • 1
  • 1
chwi
  • 2,752
  • 2
  • 41
  • 66
  • possible duplicate of [Qt Signals and Slots object disconnect?](http://stackoverflow.com/questions/9264750/qt-signals-and-slots-object-disconnect) – Thomas Ayoub Sep 25 '14 at 08:02
  • 3
    You can disconnect the signal from the slot : `disconnect(ui->btnActivate, SIGNAL(clicked()),this, SLOT(startProcess()));` – Nejat Sep 25 '14 at 08:05
  • @Nejat Thank you, this worked. I did not want to use the destructor so this was perfect. – chwi Sep 25 '14 at 08:07

1 Answers1

1

Simply use 1 of the 5 signatures of QObject::disconnect to simply remove a connection between 2 objects without destroying any of them.

Antwane
  • 20,760
  • 7
  • 51
  • 84