PDA

View Full Version : select estimate comboBox,date et time



aymenkn
27th March 2014, 19:20
Hello, I want selects the contents of a ComboBox, and DateEdit TimeEdit
This did not work
it displays only the mat field



QSqlQuery qry;
qry.prepare("select * from Etudiant");
if(qry.exec()){
while(qry.next()){
ui->lineEdit_matE->setText(qry.value(0).toString());
ui->comboBox_sexE->setCurrentIndex(qry.value(1).toInt());
ui->dateEdit_dateA->setDate(qry.value(2).toDate());
ui->timeEdit_heureA->setTime(qry.value(3).toTime());
}

ChrisW67
27th March 2014, 21:30
What would you like us to do about it? What have you tried to do about it?

Does the table contain four columns?
Does the second column contain an integer? Does that integer match an entry in the combobox?
Does the third column contain something that can be converted to a date?
Does the fourth column contain something that can be converted to a date?

aymenkn
27th March 2014, 23:04
I want to retrieve the data of database to display it in my interface

I have a problem with this code the following data: sex, date and time
will not display in ComboBox, and dateEdit timeEdit

What should I do

ChrisW67
28th March 2014, 05:28
You could start by answering the questions.

Lesiok
28th March 2014, 08:56
First of all SQL query like "SELECT * FROM name_of_table" does not guarantee the order of columns in a reply. You must explicitly specify the columns in the query or the take values ​​by name instead of index.