[PyQt] QSqlRelationTableModel default values

Scott Frankel frankel at circlesfx.com
Fri Aug 14 08:35:30 BST 2009


Hello,

What's the proper way to set default values for a relational table  
model when adding a new row?

The documentation for setData() says that for relational columns, the  
value must be the index, not the display value.  Yet when I do this,  
the table view displays the numeral rather than the string value  
associated with it via setRelation().  I've tried adding Qt.EditRole  
or Qt.DisplayRole to setData() to no avail.  eg:

	self.taskModel.setData(self.taskModel.index(row, COLOR_ID),  
QtCore.QVariant(name), QtCore.Qt.EditRole)

Suggestions?

Thanks in advance!
Scott




More information about the PyQt mailing list