def __init__(self,parent,db): self.view = qt.QTableView(parent) self.model = qt.QSqlQueryModel() self.statementFormat = """SELECT Series.SeriesNumber, Series.SeriesDescription, Series.SeriesDate, Series.SeriesTime, Series.SeriesInstanceUID FROM Series WHERE Series.StudyInstanceUID='{StudyInstanceUID}' ORDER BY Series.SeriesNumber ; """ self.query = qt.QSqlQuery(db) self.query.prepare(self.statementFormat.format(StudyInstanceUID='Nothing')) self.query.exec_() self.model.setQuery(self.query) self.view.setModel(self.model) self.view.sortingEnabled = False self.view.setSelectionBehavior(self.view.SelectRows) self.view.setSelectionMode(self.view.SingleSelection) self.view.setColumnWidth(0, 250) self.view.setColumnWidth(1, 100) self.view.setColumnWidth(2, 150) self.view.setColumnWidth(3, 100) self.view.setColumnWidth(4, 180) self.view.setColumnWidth(5, 180) self.view.setColumnWidth(6, 180) self.view.verticalHeader().visible = False
def __init__(self,parent,db): self.view = qt.QTableView(parent) self.model = qt.QSqlQueryModel() self.statement = """ SELECT Patients.PatientsName, Patients.PatientID, Patients.PatientsBirthDate, Studies.StudyDate, Studies.StudyDescription, Studies.ModalitiesInStudy, Studies.StudyInstanceUID FROM Patients,Studies WHERE Patients.UID=Studies.PatientsUID ORDER BY Patients.PatientsName ; """ self.query = qt.QSqlQuery(db) self.query.prepare(self.statement) self.query.exec_() self.model.setQuery(self.query) self.view.setModel(self.model) self.view.sortingEnabled = False self.view.setSelectionBehavior(self.view.SelectRows) self.view.setSelectionMode(self.view.SingleSelection) self.view.setColumnWidth(0, 250) self.view.setColumnWidth(1, 100) self.view.setColumnWidth(2, 150) self.view.setColumnWidth(3, 100) self.view.setColumnWidth(4, 180) self.view.setColumnWidth(5, 180) self.view.setColumnWidth(6, 180) self.view.verticalHeader().visible = False