Hello,
I found a solution that works perfectly for display but when I change the value of the ComboBox, the value of lineEdit remains the same.
here is the code for this solution:
model->setQuery("SELECT Nom FROM Projet.dbo.Produit");
ui->comboBox->setModel(model);
query.prepare("SELECT Matricule FROM Projet.dbo.Produit WHERE Nom=:nom");
query.bindValue(":nom", ui->comboBox->currentText());
if (query.exec() && query.next()) {
ui->lineEdit_3->setText(query.value(0).toString());
}
this->model = new QSqlQueryModel();
model->setQuery("SELECT Nom FROM Projet.dbo.Produit");
ui->comboBox->setModel(model);
QSqlQuery query;
query.prepare("SELECT Matricule FROM Projet.dbo.Produit WHERE Nom=:nom");
query.bindValue(":nom", ui->comboBox->currentText());
if (query.exec() && query.next()) {
ui->lineEdit_3->setText(query.value(0).toString());
}
To copy to clipboard, switch view to plain text mode
For information, in my database each 'nom' (displayed in comboBox) corresponds to a single 'id' (displayed in a lineEdit).
Is there a method to the value of lineEdit changes when the ComboBox is changed? Thank you in advance
Bookmarks