Qt-QComboBoxg清空所有的方法


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