选择估算组合框,日期和时间

select estimate comboBox,date et time

本文关键字:日期 时间 组合 选择      更新时间:2023-10-16

我想选择一个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()); 
    }
}
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."
}

您将看到它是否返回一个值