Forcing PyQt6 to update part of a window that is not on screen
-
Say I have this example code that displays a window that alternates between white and black:
from PyQt6.QtWidgets import QApplication, QWidget from PyQt6.QtCore import QTimer app = QApplication([]) window = QWidget() window.setStyleSheet("background-color: white;") window.show() def toggle_color(): current_color = window.styleSheet() new_color = "background-color: black;" if current_color == "background-color: white;" else "background-color: white;" window.setStyleSheet(new_color) timer = QTimer() timer.timeout.connect(toggle_color) timer.start(500) app.exec()
On windows 10, if I use any recording software, for example OBS, to capture the content of the window, and then drag it so that part of it is offscreen, it produces the following:
It creates tearing, which appears to be the result of the part of the window that is not visible not updating.Is there any way to force PyQt6 to update the part of the window that is not visible on the screen? I have tried update() and redraw() with and without arguments, to no avail.