dragon
21st December 2006, 20:29
Hello anyone,
Iám newbe,
I have a mainWindow with a lineEdit called leFirst.
Ihave also a dialog called searchDialog with one combobox with 4 different names.(items)
When i call the dialog in my MainWindow en select one item on the combobox i want that item been search in my database and put the result to my lineEdit in my MainWindow.
code snippet:
void MainWindow::search()
{
searchDialog dlg(this);
if( dlg.exec() == QDialog::Accepted) {
QSqlQuery query("SELECT firstname FROM person");
QString name = dlg.nameComboBox->currentText();
if ( query.next() )
name = (query.value(0).toString());
leFirst->setText( name);
}
}
This works fine only for the first name in the combobox and showing up in the lineEdit.
When i choose for the second name in the combobox ( the second item) then in lineEdit only shows the first name again and not the second name.
Is something wrong in my code or missing something.
I have tried severall options but nothing works.
Thanks in advance.
Iám newbe,
I have a mainWindow with a lineEdit called leFirst.
Ihave also a dialog called searchDialog with one combobox with 4 different names.(items)
When i call the dialog in my MainWindow en select one item on the combobox i want that item been search in my database and put the result to my lineEdit in my MainWindow.
code snippet:
void MainWindow::search()
{
searchDialog dlg(this);
if( dlg.exec() == QDialog::Accepted) {
QSqlQuery query("SELECT firstname FROM person");
QString name = dlg.nameComboBox->currentText();
if ( query.next() )
name = (query.value(0).toString());
leFirst->setText( name);
}
}
This works fine only for the first name in the combobox and showing up in the lineEdit.
When i choose for the second name in the combobox ( the second item) then in lineEdit only shows the first name again and not the second name.
Is something wrong in my code or missing something.
I have tried severall options but nothing works.
Thanks in advance.