<posted & mailed> On Friday 02 March 2007 21:55, Mel wrote:
[This message is a bit old now. Still...] > Now that I can change the row colors of QTableView when loading data I > now need to be able to set the color of the row at anytime. I've been > trying by using an item delegate but I'm not sure if I'm using it > correctly. Thinking about it a bit, I'd probably avoid using a delegate for this. Ideally, you want to influence the BackgroundRole for each item in the row somehow. > Would I try and set an item delegate for the row and > change the background color that way? An example or a link to easy > to understand documentation on changing a row color for an object > based on QTableView using QSqlQueryModel as a model would be greatly > appreciated. I'm still a bit confused in Qt4. That's a very specific request! Anyway, using QTableView and QSqlQueryModel together is quite common, but we can look at a way to achieve this. One way would be to store a list of colors in the custom model, or use another database table to hold them, and access these whenever you need to return BackgroundRole data for any item in a row. You could lazily initialize these colors by setting each one when the corresponding row is accessed for the first time, and only updating it when the relevant item in the row is modified. David -- http://mail.python.org/mailman/listinfo/python-list