QLabel锯齿设置Antialiasing无效,求解决
-
有人来帮忙看看吗?这个问题怎么解决?我想在QLabel上加载图片,并且设置为圆角,设置圆角成功了,但是锯齿严重,下面是我的代码,哪位大神帮忙看看,谢谢了
QPixmap QLabelUtils::pixmapToRound(QPixmap& src, int x, int y, int width, int height, int radius) { if (src.isNull()) { return QPixmap(); } QSize size(width, height); QBitmap mask(size); QPainter painter(&mask); painter.setRenderHints(QPainter::Antialiasing|QPainter::SmoothPixmapTransform); painter.fillRect(x, y, size.width(), size.height(), Qt::white); painter.setBrush(QColor(0, 0, 0)); QPainterPath path; path.addRoundedRect(x, y, size.width()-1, size.height()-1, radius, radius); path.translate(0.5, 0.5); painter.drawPath(path); QPixmap image = src.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); image.setMask(mask); return image; }
我的Qt版本是6.4。
太折磨人了,烦请大神们帮忙看看。