Tianxiang Xiong
Tianxiang Xiong

Reputation: 4101

Fitting signals to slots in Qt

I'm trying to enable a QPushButton after another QPushButton is clicked and I've run into a problem. The first QPushButton can emit a clicked() signal while the second QPushButton only has slots of the form setEnabled(bool) and setDisabled(bool).

Basically, I'm trying to do

connect(ui->pbViewVolume,  SIGNAL(clicked()), 
        ui->pbSaveAsImage, SLOT(setEnabled(true)));

Since it's not possible to send a signal with fewer parameters than the slot, how can I best do this? The only way I see is to create a public slot for my MainWindow like

void EnableSaveAsImageButton(){
    ui->pbSaveAsImage->setEnabled(true);
}

but I'd rather not fill my MainWindow with this sort of rubbish function.

Upvotes: 1

Views: 75

Answers (1)

hank
hank

Reputation: 9873

  1. You have to create that slot.
  2. You don't need to make that slot public, make it private.
  3. This function is not rubbish.

Upvotes: 1

Related Questions