Thanks everybody for answers.
Chris, I tried to follow your instructions but it was really difficult because it's my first time I use Qt and my version is in French. Anyway, if there is a tutorial video, it will be great. And Thanks again!
Lykurg, I'm not really good at programming and this is my first program in Qt Here I tried to do as you have told me but it did not work.
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());
}
QObject::connect(ui
->comboBox,
SIGNAL(currentIndexChanged
(int)),ui
->lineEdit_3,
SLOT(setText
(ui
->comboBox
->currentText
())));
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());
}
QObject::connect(ui->comboBox, SIGNAL(currentIndexChanged(int)),ui->lineEdit_3, SLOT(setText(ui->comboBox->currentText())));
To copy to clipboard, switch view to plain text mode
What should I do? Thank you in advance
Bookmarks