How to clear the items of comboBox
-
Hi,everyone.
Now I have two comboBox:box1,and box2.I want the box2 being changed when the box1 is changing.The code below;
@void MainWindow::on_proComboBox_currentIndexChanged(int index)
{
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GB2312"));
QString GuangdongPro[5]={"广州","揭阳","深圳","佛山","汕头"};
QString ZhejiangPro[3]={"杭州","宁波","温州"};
QString HunanPro[2]={"长沙","株洲"};if(index==0) { ui->cityComboBox->clear(); for(int i=0;i<5;i++) ui->cityComboBox->setItemText(i,GuangdongPro[i]); }
.....
.....
@But I found that while I had changed the box1,the old items of the box2 was cleared,and the new items wasn't appeared yet.
anyone have good idea?
-
Oh,t3chNo,you're right. I was confused at that time.
Many thanks.