QComboBox的currentIndexChanged信号死循环问题

 

connect(m_pComboBoxDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(sltComboBoxDeviceCurrentTextChanged(int)));

void VideoGrid::updateListWidgetData()
{
  //就像给信号量加锁一样:
  m_pComboBoxDevice->blockSignals(true);   //锁上。addItem更改值时不触发currentIndexChanged信号
  m_pComboBoxDevice->addItem(list[0]);
  m_pComboBoxDevice->blockSignals(false);   //解锁
}

void VideoGrid::sltComboBoxDeviceCurrentTextChanged(int index)
{
    updateListWidgetData();
}

 

posted @ 2019-09-23 15:42  远方是什么样子  阅读(1570)  评论(0编辑  收藏  举报