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

Windows fail to show after being hidden, if run without window manager

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.2.3, 6.3.0
    • Widgets: Main Window
    • None
    • Windows 21H2 19044.1654
      Ubuntu 20.04.4 LTS (WSL2)
      Python 3.10.4
      PyQt6 6.2.3, 6.3.0
      PyQt5 5.15.6
    • Linux/X11

    Description

      Hello,

      I am testing a Qt application written pin Python using Xvfb and I noticed that when I show and hide and then show again the main window, it will not draw. From the point of view of code the window appears to be showing, but what Xvfb sees is black screen.

      To reproduce, in Python, install PyQt6, then run `xvfb-run demo.py`, where the contents of the file are as follows:

      from PyQt6.QtGui import QColor
      from PyQt6.QtWidgets import QMainWindow, QApplication
      app = QApplication([])
      window = QMainWindow()
      def get_window_color():
       window_screenshot = window.screen().grabWindow(window.winId()).toImage()
       return QColor(window_screenshot.pixel(5, 5)).name()
      window.show()
      app.processEvents()
      print("window color before hiding", get_window_color())
      window.hide()
      app.processEvents()
      window.show()
      app.processEvents()
      print("window color after hiding and showing", get_window_color())
      

      Observe that the output is 

      window color before hiding #efefef
      window color after hiding and showing #000000

       If using Windows, you can also reproduce by running VcXsrv in "One large window" mode, and then on WSL2 / Ubuntu run `DISPLAY=$(ip route list default | awk '{print $3}'):0 python` and paste the above code. You will see the window appearing, disappearing, and failing to appear again.

      The issue does not manifest if running the same code with Qt5, or if running the above code with VcXsrv in the "Multiple windows" mode.

      I have found a few similar issues but they all seemed to have been reported for Qt 4 or 5, so I am creating a new issue. Sorry if I did something wrong! I'm new here.

      Initially reported on the forum here: https://forum.qt.io/topic/136295/on-qt6-main-window-fails-to-show-after-being-hidden-if-run-without-window-manager

      Attachments

        Issue Links

          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
              squirrel squir rel
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes