Pythonguis iconPythonguisSep 2, 2026 ~1 min source read

Python GUIs: Understanding QPainter Coordinates in PyQt6 — How the coordinate system works for drawing on canvases in PyQt6

I really having trouble understanding the coordinate system used in QPainter. If you've started drawing with QPainter in PyQt6, you might have been surprised the first time you drew a line.

Python GUIs: Understanding QPainter Coordinates in PyQt6 — How the coordinate system works for drawing on canvases in PyQt6

Share this story

Send the public story page.

Useful takeaways from this story.

I really having trouble understanding the coordinate system used in QPainter.

If you've started drawing with QPainter in PyQt6, you might have been surprised the first time you drew a line.

Here's a simple diagram to illustrate: python (0,0) &boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxhâ–º x increases &boxv &boxv &boxv &boxv â–¼ y increases So when you call...

Building the complete brief

The page is ready to read now. The fuller skim-friendly version will appear here automatically.

The useful part

I really having trouble understanding the coordinate system used in QPainter. If you've started drawing with QPainter in PyQt6, you might have been surprised the first time you drew a line. That's because QPainter uses a coordinate system where the origin (0, 0) is in the top-left corner of the canvas, not the bottom-left.

How it works

  • This catches a lot of people off guard, so in this tutorial we'll walk through exactly how QPainter coordinates work, how to visualize them, and how to convert between screen coordinates and the...
  • In most math courses, you learn to plot points on a Cartesian plane where (0, 0) is at the bottom-left.
  • QPainter (and most screen-based graphics systems) does things differently: (0, 0) is at the top-left corner of the drawing surface.
  • This means that as your y value gets larger, you move down the screen, not up.
  • Here's a simple diagram to illustrate: python (0,0) &boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxh&boxhâ–º x increases &boxv &boxv &boxv &boxv â–¼ y increases So when you call...

Details worth keeping

The x-axis increases to the right, and the y-axis increases upward. The x-axis increases to the right (same as math). The y-axis increases downward (opposite of math).

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