我使用:Qt的5 QComboBox setCurrentIndex
UI-> Combobox-> setCurrentIndex(1);
但這指令不調用函數
空隙on_comboBox_currentIndexChanged(常量的QString & ARG1);
爲什麼會這樣?
void ConsigneMouvement::show(int AxeType)
{
axeType = AxeType;
switch(axeType)
{
case 1:
ui->comboBox->setCurrentIndex(0);
ui->comboBox->setEnabled(true);
break;
case 2 :
ui->comboBox->setCurrentIndex(1);
ui->comboBox->setEnabled(false);
break;
case 3 :
ui->comboBox->setCurrentIndex(0);
ui->comboBox->setEnabled(true);
break;
case 4 :
ui->comboBox->setCurrentIndex(0);
ui->comboBox->setEnabled(true);
break;
}
this->exec();
}
和功能
void ConsigneMouvement::on_comboBox_currentIndexChanged(const QString &arg1)
{
if(arg1 == "Absolu")
ui->label_distance->setText(tr("Position"));
else
ui->label_distance->setText(tr("Distance"));
}
你能提供一個[簡單,完整的示例代碼](http://sscce.org),它顯示了這個問題? – 2013-05-07 07:50:10
您的索引是否真的發生了變化?如果以前的索引也是1,則信號不會發出。 – Amartel 2013-05-07 07:53:54
您是否剛剛將示例代碼作爲答案發布?這是不可接受的,通過'編輯'按鈕添加您的問題,並刪除'答案'。 – cmannett85 2013-05-07 08:06:19