Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-113346

QHeaderView draws outside itself when model updates coincide with scroll events

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5.0
    • Widgets: Itemviews
    • None
    • Windows 11
    • Windows

    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.

      Attachments

        1. CMakeLists.txt
          0.3 kB
        2. output.png
          output.png
          5 kB
        3. test.cpp
          2 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            patstew Patrick Stewart
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes