Question

I have the following widget:

pixmap = QtGui.QPixmap(r'pics\cdaudio.png').scaled(100, 100)

The image is scaled down, from 256x256. It looks pretty choppy:

enter image description here

How can I scale it smoothly from within Qt?

Was it helpful?

Solution

Use the transformMode parameter:

pixmap = QtGui.QPixmap(r'pics\cdaudio.png').scaled(100, 100, transformMode=QtCore.Qt.SmoothTransformation)

OTHER TIPS

According to @iTayb, here's what I came up with:

// Scale the source to the requested size with 
//  the KeepAspectRatio as aspectMode & SmoothTransformation as mode
*source = source->scaled(width, height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
target->setPixmap(*source);

Why not using the SVG format (and the Qt SVG module for this) if possible ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top