Qt QComboBox清空所有的方法


1.clear()会清空关系,而且在我这会卡,很慢也不报错清完全要2分钟

2.我的方法:

 1 for (int i = 0; i < 7; i++)  2  {  3             // strListTemp << dt.addDays (i).toString (strDateFromat);
 4             ui.beginTime_comboBox->insertItem (i, dt.addDays (i).toString (strDateFromat));  5             ui.endTime_comboBox->insertItem (i, dt.addDays (i).toString (strDateFromat));  6  }  7 
 8  ControlFunction::romoveAllItem (ui.beginTime_comboBox);  9  ControlFunction::romoveAllItem (ui.endTime_comboBox); 10         ui.beginTime_comboBox->setCurrentIndex (0); 11         ui.endTime_comboBox->setCurrentIndex (ui.endTime_comboBox->count() - 1); 12         return true;
 1 void ControlFunction::romoveAllItem (QComboBox *cb)  2 {  3     int atemp = cb->count();  4 
 5     for (; atemp >= 7; atemp--)  6  {  7         cb->removeItem (atemp);  8         // cb->setItemText (atemp, "ddd");
 9  } 10 }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM