我重新实现了QGraphicsView,以通过鼠标滚轮事件缩放场景。该场景包含多个QGraphicsPixmapItem。滚轮事件调用QGraphicsView::scale(qreal sx, qreal sy)
除了渲染之外,一切都很完美。当我缩小(场景变小)时,会出现锯齿。我尝试在重新实现的 QGraphicsView 构造函数中设置渲染提示,如下所示:
ImageViewer::ImageViewer(QWidget * parent) :
QGraphicsView(parent)
{
setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing);
}
我仍然看到这些文物。我怎样才能摆脱这个?
最佳答案
请参阅我对 this question 的评论.
基本上,您必须在要应用抗锯齿功能的 QGraphicsPixmapItem
上调用 setTransformationMode(Qt::SmoothTransformation)
。
在 View 上调用 setRenderHints
对我来说也不起作用。
关于qt - 抗锯齿在 QGraphicsView 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17734290/