qt

How to edit a buttons connection in Qt


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


Solution

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