Pythonguis iconPythonguisDec 2, 2026 ~1 min source read

Python GUIs: Clearing the canvas in QPainter — Fix the common black background issue when painting on a QPixmap in PyQt6

My canvas is not clearing every time I run my painting app, and on Windows the background appears black instead of white. How do I properly clear or fill the canvas when using QPainter and QPixmap in PyQt6? If you've been following along with QPainter tutorials and find that your canvas has a black background — or that

Python GUIs: Clearing the canvas in QPainter — Fix the common black background issue when painting on a QPixmap in PyQt6

Share this story

Send the public story page.

Keep reading in the app

Open the app view to save this story, compare related coverage, and continue from the same source.

Open in app