user1936620
user1936620

Reputation: 11

QGraphicsItem: disable antialiasing when scaled

i have a custom QGraphicsItem to draw some primitives using QPainterPath. When i scale up the scene i would like to see pixels of that paths without anti aliasing. Just like you see the QPixmap pixels when zooming.

I already set render hint to disable painter anti aliasing but it doesn't seem to take any effect. At least it is very small.

Is there a way to display pixels on high zoom level? Or something looking like pixels.

Upvotes: 1

Views: 870

Answers (1)

paulm
paulm

Reputation: 5882

The only way I can think of doing this is as follows:

Use QPixmapCache (or just a member QPixmap) in your QGraphicsItem. Before zooming render your QGraphicsItem to the QPixmap.

Now in your paint you can just draw the QPixmap - hence when this is zoomed you'll "see" the pixels.

This also has the advantage of speeding up your painting if your object has a complex paint().

Upvotes: 1

Related Questions