You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, May 31st 2012, 6:09am

QItemDelegate / QSortFilterPoxyModel

I've got a QTableView setup. It is having rows filtered out by a subclassed QSortFilterProxyModel, and it is being painted by a subclassed QItemDelegate. The table continually has items added to it. Imagine ping replies, where each line would represent a row. Everything works, except that when I add a row, paint() is called for each cell... including those not shown in the viewport. If I have 1999 rows and 5 columns, when I insert the next item, paint() will be called 10,000 times (even though about 10 rows are showing).

I thought the essence of the model/view paradigm was that it only paints what is visible to the user. Am I doing something wrong?

EDIT: Okay, the problem is b/c instead of using the Proxy for all removal of rows (not just not-allowing some in) I was manually setting the rowHeight to 0 in the view.

Hmm... not sure how to do this. Some rows need to be removed intermittently. I found that calling invalidate() is useless b/c it will then call filterAcceptsRow() on all rows -- visible or not. reset() was not any better.

Guess I need to approach this differently. Or I'm missing something fundamental about the filter, and invalidating it.

EDIT2: I guess the answer would be calling invalidate() only if the line that needs to be removed is visible. Hmm....

This post has been edited 2 times, last edit by "kiss-o-matic" (May 31st 2012, 7:36am) with the following reason: Found something