QComboBox激活(int)

时间:2013-12-26 16:23:16

标签: c++ qt

我正在使用qt 5.2。我的连接功能的电话:

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

节目打印:

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

1 个答案:

答案 0 :(得分:6)

你尝试使用的信号被激活(int),我不知道你为什么要尝试连接激活(0)。它应该是这样的:

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

如果要使用项索引过滤操作,则应将参数传递给插槽,并执行特定操作,例如:

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