user2778712
user2778712

Reputation:

QComboBox activated(int)

I'm using qt 5.2. My connect function's call:

QObject::connect(ui->mycombobox, SIGNAL(activated(0)), ui->mypushbutton, SLOT(toggle()));
// When I select first element from mycombobox, mypushbutton must be disabled

Program prints:

QObject::connect: No such signal QComboBox::activated(0) in <myfile>

Upvotes: 1

Views: 6054

Answers (1)

Blood
Blood

Reputation: 4186

Signal which you try to use is activated(int), i have no idea why you are trying to connect activated(0). It should be like this:

QObject::connect(ui->mycombobox, SIGNAL(activated(int)), ui->mypushbutton, SLOT(toggle()));

If you want to filter action using item index, you should pass argument to your slot and there perform specific action for e.g.:

QObject::connect(ui->mycombobox, SIGNAL(activated(int)), this, SLOT(mySlot(int)));
/*...*/
void MyClass::mySlot(int arg)
{
    if(arg == 0)
          ui->mypushbutton.toggle();
}

Upvotes: 7

Related Questions