model->setQuery("SELECT s.scan_date,p.surname,p.first_name,p.nric_no,p.dob,p.gender,r.description FROM PATIENT p,RACE r, SCAN_DATA s WHERE p.race = r.race AND p.patient_id=s.patient_id AND p.surname = '" + patientNamestr + "'");
model
->setHeaderData
(0, Qt
::Horizontal,
QObject::tr("Scan Date"));
model
->setHeaderData
(1, Qt
::Horizontal,
QObject::tr("Surname"));
model
->setHeaderData
(2, Qt
::Horizontal,
QObject::tr("First name"));
model
->setHeaderData
(3, Qt
::Horizontal,
QObject::tr("NRIC"));
model
->setHeaderData
(4, Qt
::Horizontal,
QObject::tr("DOB"));
model
->setHeaderData
(5, Qt
::Horizontal,
QObject::tr("Gender"));
model
->setHeaderData
(6, Qt
::Horizontal,
QObject::tr("Race"));
view->setModel(model);
view->show();
QSqlQueryModel *model;
QTableView *view;
model = new QSqlQueryModel;
view = new QTableView;
model->setQuery("SELECT s.scan_date,p.surname,p.first_name,p.nric_no,p.dob,p.gender,r.description FROM PATIENT p,RACE r, SCAN_DATA s WHERE p.race = r.race AND p.patient_id=s.patient_id AND p.surname = '" + patientNamestr + "'");
model->setHeaderData(0, Qt::Horizontal, QObject::tr("Scan Date"));
model->setHeaderData(1, Qt::Horizontal, QObject::tr("Surname"));
model->setHeaderData(2, Qt::Horizontal, QObject::tr("First name"));
model->setHeaderData(3, Qt::Horizontal, QObject::tr("NRIC"));
model->setHeaderData(4, Qt::Horizontal, QObject::tr("DOB"));
model->setHeaderData(5, Qt::Horizontal, QObject::tr("Gender"));
model->setHeaderData(6, Qt::Horizontal, QObject::tr("Race"));
view->setModel(model);
view->setSelectionBehavior(QAbstractItemView::SelectRows);
view->setSelectionMode(QAbstractItemView::SingleSelection);
view->show();
To copy to clipboard, switch view to plain text mode
Bookmarks