Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.0
-
None
-
Windows 11
Description
QHeaderView seems to be able to draw outside itself, onto the widget above the enclosing QTableView, when the model is resetting or adding/removing rows and scrolling is happening. I have attached a testcase, if you drag the scrollbar up and down in the test application it happens fairly quickly. In the test app I'm only getting one row drawn above the headerview, but in my own application it's drawing several rows outside occasionally. It might be related to my actual model doing a bunch of insertrows/removerows rather than just doing resetmodel as in the test. I have only noticed this issue since updating from 6.3.2 to 6.5.
From what I can tell in the debugger, the problem seems to be that the offset and length in QHeaderView's private object are updated at different times when rows are added/removed from the model, and scroll/draw events can happen inbetween. In addition, the paintEvent doesn't seem to do any clipping. So it gets into a state where in QHeaderView::paintEvent offset > length, so visualIndexAt returns -1 for start and end, which then get set to 0 and count(), which then results in it trying to draw a header for every single row in the model, using a currentSectionRect that is entirely outside the translatedEventRect, and entirely outside the QHeaderView. Those draws don't appear to be clipped to the QHeaderView, or the QTableView, so they occur on top of other widgets.