Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Forcing PyQt6 to update part of a window that is not on screen
Forum Updated to NodeBB v4.3 + New Features

Forcing PyQt6 to update part of a window that is not on screen

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 277 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    end3potent
    wrote on last edited by
    #1

    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:
    1530f4e7-7754-4609-af4d-bd4304bace02-image.png
    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.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved