PDA

View Full Version : Force repaint of a QItemDelegate...



hickscorp
29th April 2011, 23:48
Hello,

i have a simple window containing two QTableViews. Each one of them is QSqlTableModel based. The first table however defines what is displayed in the second table (One - to - many relation ship, so when one selects an item in the first table, the many linked items via foreign key are updated and displayed in the second table).

Both tables have a set of editors defined via customized QItemDelegate subclasses (Checkboxes, progress bars, icons, etc).

The first table is displaying a few virtual columns (i subclassed the QSqlTableModel behind the table to allow that), so these virtual columns display information about the foreign linked items, including their count based on several conditions).

My problem now is that when the user interacts with the 2nd table and changes the data in the items, i'd like to be able to "repaint" the generated QItemDelegate columns of the first table without loosing the selection... And for now the only solution i have found is to call repaint() on my whole first table... But i feel it's really dirty since i would only have to repaint the selected rows virtual column widgets...

How can i retrieve a pointer to the generated widgets for my custom columns and then call repaint on them only for the selected row? i have tried a lot of things, via the table selection model, via the model itself, via the de-re-selection of the selected item... But none of them are satisfacting enough.

Thanks a lot,
Pierre.