//创建下拉框对象,并加入到表格对象中 
QComboBox *comboBox = new QComboBox (); comboBox ->addItems(strListItems);//QStringList类型的元素 m_Table->setCellWidget(0,0,comboBox );//把下拉框加入到表格中
//如果表格的一行中既有QComboBox 类型的元素,也有QTableWidgetItem类型的元素,可以采用下面的方式来用: for(int col = 0; col < count; col++) {   if( QComboBox *comboBox = dynamic_cast<QComboBox *>(table->cellWidget(0, col))   {     comboBox->setCurrentIndex(index);//让下拉框选到index对应的位置   }   else   {     table->setItem(0,col,new QTableWidgetItem("value");   } }

 

相关文章:

  • 2021-11-23
  • 2021-10-05
  • 2022-03-04
  • 2021-12-15
  • 2022-02-13
  • 2021-06-15
  • 2021-10-16
猜你喜欢
  • 2022-12-23
  • 2022-01-29
  • 2021-09-25
  • 2022-12-23
  • 2022-02-02
  • 2021-12-09
  • 2022-12-23
相关资源
相似解决方案