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

QWidget painting intermittently shows obscured background as lines between widgets (MS Windows)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • None
    • 6.0.1, 6.0.2, 6.0.3, 6.0.4, 6.2.3, 6.3.0 Beta2
    • None
    • Windows

    Description

      Background

      While attempting to upgrade the Joulescope UI [GitHub from PySide2/Qt5.15 to PySide6/Qt6, I encountered a strange rendering issue on Windows 11.  My widget displayed the background, despite the background being obscured, like this:

      The rendering artifact comes and goes at different places depending upon the widget size.

      Demonstration

      I created a simplified example using PySide6/Qt6 to better demonstrate the issue.  The red lines are the QMainWindow background which is incorrectly visible between widgets with a QGridLayout with zero spacing:

      As you drag the lower-right corner to resize the window, the lines disappear and reappear in different locations.  It's best to see it in action with the attached "demo.gif". 

      The code is in the attached pyside6_render_artifacts.py.  

      I worked with Selmen D to replicate the issue in C++/Qt6.  He was able to recreate the same behavior on all versions of Qt 6 that he tried: 
      Qt 6.0.1, Qt 6.0.2, Qt 6.0.3, Qt 6.0.4, Qt, 6.2.3 and Qt 6.3.0 Beta

      With his permission, I have attached his C++ code as pyside6_render_artifacts_cpp.zip.

      Expected Behavior

      The background color should never peak through widgets with no spacing.  The demonstration application above should never display visible red lines.

      Attempts to Isolate Issue

      Selmen attempted to further isolate the issue with Qt.

      1) His first idea was that some calculation was wrong with the labels of the size or the positions when resizing.  When he made an example to calculate the position and print the result, it is the same for Qt5 and Qt6 but the problem occurs only on Qt6.

      2) The second idea is that something is when wrong for the label in the paint event in Qt, so he created a new component.  The new component's paint event painted a filled rectangle with green color.  The image below contains 4 of these components:

      You can see the problem between components 2 and 3.  The view is QVBoxLayout, while our original example used QGridLayout.  So, this error is not restricted to just QGridLayout.

      3) Both examples run correctly with Qt 5.15.  We do not see these painting artifacts with Qt 5.15.  This is a new issue with Qt 6.

      4) When changing the screen resolution while running these examples, the line disappears with some resolutions.  

      5) In a dual monitor setup with different screen sizes, dragging the demo app from the bigger screen to the smaller screen causes the red line artifact to disappear.

      6) Ubuntu with Qt 6 does not exhibit this issue.

      7) An equivalent Qt QML application does not exhibit this issue.  See pyside6_render_artifacts_qml.zip.

      In our opinion, this appears to be an issue with Qt rendering pixels under Windows.  Both of us are unfamiliar with this part of Qt.

      We believe that this issue is Windows only.  The problem does not occur under Linux.  The issue also does not occur on all Windows machines.  I successfully duplicated the issue on two machines with Nvidia graphics cards, and Selmen's computer exhibited the issue.  I tried disabling the Nvidia graphics card on one machine to use the integrated Intel graphics, but the problem persisted.  Another Windows 11 PC with only integrated graphics and 1920x1080 resolution did reproduce this behavior.

      Workaround

       We have not yet come up with a workaround for Qt 6.  For the time being, I will keep the Joulescope UI on Qt 5.15.

      References

      I initially created a topic on the forum Desktop rendering issue with QGridLayout, Windows, Nvidia, PySide6.  

      This search did not return any similar results, which led to the creation of this bug:

      issuetype = Bug AND status = Open AND affectedVersion ~ "6*" AND "Platform/s" = Windows AND text ~ "widget"

      Attachments

        1. demo.gif
          demo.gif
          828 kB
        2. image-2022-02-20-11-13-49-049.png
          image-2022-02-20-11-13-49-049.png
          52 kB
        3. pyside6_render_artifacts.py
          3 kB
        4. pyside6_render_artifacts_cpp.zip
          3 kB
        5. image-2022-02-20-11-36-11-215.png
          image-2022-02-20-11-36-11-215.png
          155 kB
        6. pyside6_render_artifacts_qml.zip
          1 kB
        7. qtdiag.txt
          13 kB
        8. image-2022-02-20-12-09-51-761.png
          image-2022-02-20-12-09-51-761.png
          96 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
            mliberty Matt Liberty
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes