[PyQt] QSqlRelationalDelegate and table id's

Scott Frankel frankel at circlesfx.com
Thu May 7 23:30:49 BST 2009


Hello,

Is there a way to test for SQL table ID numbers in an  
QSqlRelationalDelegate.paint() method?

The attached example app paints a background color on specific rows of  
a QTableView, by overriding an QSqlRelationalDelegate.paint() method.   
I pass the row numbers to paint() in a list that I create from the  
results of an QSqlQuery(), collecting table ID numbers.

My app works fine until a user sorts the table view.  The paint()  
method only knows about table row numbers, so the painted rows stay  
static while the entries are repositioned from the sort.  Furthermore,  
the delegate only knows about the data it's displaying, so testing for  
the contents of the first column (even if it weren't hidden) would  
fail if the user scrolled it out of view.

Suggestions?  I'm stymied.

I'd also like to know what the default QSqlRelationalDelegate text  
alignment is set to.  More importantly, I'd like to know how to  
replicate it.  It appears to be neither Qt.AlignLeft nor  
Qt.AlignCenter, but something with a "pad."  Note that my painted rows  
have misaligned text relative to the unpainted rows.

Thanks in advance,
Scott



-------------- next part --------------
A non-text attachment was scrubbed...
Name: delegateTest.003.py
Type: text/x-python-script
Size: 7586 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090507/da2b66f1/delegateTest.003.bin
-------------- next part --------------









More information about the PyQt mailing list