我想选择ComboBox的内容,以及DateEdit TimeEdit 这没用 它只显示mat字段
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());
}
}
答案 0 :(得分:0)
QSqlQuery qry;
qry.prepare("select * from Etudiant");
if(qry.exec()){
if(qry.next) {
do{
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());
}while(qry.next());
}
else {
qDebug << "No results found.";
}
}
else
{
qDebug << "Unable to execute query."
}
您将看到它是否返回值。