PDA

View Full Version : QTableView only showing data when row selected



Banjo
22nd January 2009, 04:52
Hello

I have a QTableview created in Designer with the additional Python code:


self.tvObserverEffort.setModel(self.observerEffort Model)
self.tvObserverEffort.setSelectionMode(QTableView. SingleSelection)
self.tvObserverEffort.setSelectionBehavior(QTableV iew.SelectRows)
self.tvObserverEffort.hideColumn(0) # ObserverEffortId
self.tvObserverEffort.hideColumn(1) # Survey
self.tvObserverEffort.hideColumn(5) # Observer
self.tvObserverEffort.hideColumn(10) # Date
self.tvObserverEffort.setItemDelegate(QSqlRelation alDelegate(self.tvObserverEffort))
self.tvObserverEffort.horizontalHeader().setProper ty("mandatory", QVariant(True))
self.tvObserverEffort.setProperty("mandatory", QVariant(True))
self.tvObserverEffort.horizontalHeader().moveSecti on(11,0)
self.tvObserverEffort.horizontalHeader().moveSecti on(12,1)
self.tvObserverEffort.resizeColumnsToContents()
self.tvObserverEffort.setWordWrap(True)
self.tvObserverEffort.resizeRowsToContents()

I filter the model as follows:

surveyId = self.effortDayModel.record(index.row()).value("SurveyId").toInt()[0]
observerId = self.effortDayModel.record(index.row()).value("ContactId").toInt()[0]
effortDate = self.effortDayModel.record(index.row()).value("WatchDate").toDate()
filter = "ObserverEffort.SurveyId = %s AND ObserverEffort.ContactId = %s AND ObserverEffort.WatchDate = '%s'" % (surveyId, observerId, effortDate.toString("yyyy-MM-dd"))
self.observerEffortModel.setFilter(filter)
self.observerEffortModel.select()
self.tvObserverEffort.show()

The problem that I am having is that although the TableView is showing the correct number of rows when the filter is applied, the table rows only display data when a cell in the row is selected. What am I missing ??

Thanks for any help you may have

Banjo
26th January 2009, 22:53
Hello

Is anyone able to help me with this ???

Thanks

Banjo
27th January 2009, 05:34
I tracked this down to a problem in my stylesheet