缩放的QPixmap看起来很糟糕

iTa*_*ayb 4 qt qt4 qpixmap

我有以下小部件:

pixmap = QtGui.QPixmap(r'pics\cdaudio.png').scaled(100, 100)
Run Code Online (Sandbox Code Playgroud)

图像按比例缩小,从256x256.它看起来很不稳定:

在此输入图像描述

如何从Qt内平滑地缩放?

iTa*_*ayb 8

使用transformMode参数:

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


Rob*_*ert 5

根据@iTayb 的说法,这就是我的想法:

// 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);
Run Code Online (Sandbox Code Playgroud)