0
How do I update a Combobox after opening a Qdialog?
The code below does not update if you have an update in db. I have to close the application and open to show the new data:
Dialog::Dialog(){
carregar_comboBox();
}
void Dialog::carrega_comboBox(){
qry..
while..
ui->comboBox->addItem(qry.value(0).toString());
}
You must then call the
carrega_comboBox()
whenever you change something in DB. Or use a model for compobox.– Guilherme Bernal
@William Bernal has some way of calling the
carregar_comboBox()
when I open theQDialog
? It’s better than binding in otherclass
.– Hy-brazil
Implement your function
show() { carregar_comboBox(); QDialog::show(); }
.– Guilherme Bernal
Thanks. I got it working :)
– Hy-brazil
@Guilhermebernal gives an answer so we can vote.
– Maniero