问题阐述:在对combox进行了分配模型后setModel ,想要清除combox内容,发现使用clear()没有起到作用。
代码如下:
1 QSqlQueryModel *model = new QSqlQueryMode(this); 2 model->setQuery(QString("select name from brand where factory='%1'").arg(arg1); 3 ui->sellBrandComboBox->setModel(model);//分配模型
解决方法:clear没有效果后,决定对model进行更改,对comboBox赋值空的模型,代码如下:
void Widget::on_sellCancelBtn_clicked() { static QStandardItemModel emptyModel; ui->sellBrandComboBox->setMode(emptyMode);//起到作用了 //省略其他内容 }
标签:Qt,ComBox,ui,setModel,model,sellBrandComboBox From: https://www.cnblogs.com/ycbeginner/p/17167959.html