Invalidate filter sometimes doesn't cause a repaint?
-
I have a subclass of @QSortFilterProxyModel@
A bug has arisen. Correct behaviour is that, when some data are selected in a certain way, the on screen listing should show those in a different font (in this case, light grey - "greyed out"); this is done by marking the data in such a way that @ filteracceptsrow()@ returns false when I want it greyed out, and true otherwise.
They are not greyed out until the window is forced to be redrawn in some way - just clicking, or dragging another window over it, will make this happen. I suspect there's some kind of race hazard going on, as when I tried to debug it, having a breakpoint in the chain means it works correctly (i.e. with a breakpoint, when I let it run free again, the lines are greyed out, but if I remove the breakpoint and repeat, I have to force a redraw by moving a window around before the lines are greyed out).
Currently, the code looks like this:
@ hiddenMessages += messages;
invalidateFilter();@The messages to grey out are simply added to hiddenMessages , and then invalidateFilter is called, which as I understand it causes a refresh and a redraw on screen.
I'm still new to a lot of this and getting my head round the clever QT filter model. Does it sound like this is some kind of race hazard, or the like? If so, is there a better way to ensure a redraw than just calling invalidateFilter?
-
what happens when you call QSortFilterProxyModel::invalidate() instead/additionally?
-
I've been digging, and it's actually a tiny bit different (and more mystifying to me).
The panel that doesn't update unless I do something to force a redraw is a docked window, living alongside a couple of other docked windows with a tab manager to allow the user to flip between them.
If I undock this window, and put it somewhere else, it works; that is, what I do to effect the change (which is select a folder in the tree and pick the relevant option) works - the one I pick goes light grey (it's a folder) and all of the subfiles in that folder (looks like a pretty normal folder/file tree) go grey. I don't have to do anything to force a redraw.
If I leave it docked, only the folder goes grey until I do something to force a redraw (such as drag another window over the edge of it, or flip tabs and then back again).
This is driving me insane :) Does this difference mean anything? When it's the only tab there (i.e. I have undocked all the other that share that space and moved them elsewhere) it's still bad; I have to force a redraw.
-
please file a "bug report":https://bugreports.qt-project.org.
-
I'll keep digging; I'd want to be pretty sure of myself before lodging a bug report. Deeper in the code, there's some logic that examines each item to be shown (modelindex) and if the parent is the original folder I selected to be greyed out, it gets greyed out.
It seems that this comes back as false when it's not working, and as true when it is; this means that it comes back as false, then I nudge the window, and then it redraws and this time it comes back as true. As if there's some kind of race hazard; like the model isn't being updated in time for the redraw.