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



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

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

相关内容

  • 没有找到相关文章

最新更新