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 }

 

文章来自:http://www.cnblogs.com/ants-double/p/5902341.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3