【问题标题】:QPainterPath stroke artifactsQPainterPath 描边伪影
【发布时间】:2018-12-20 00:43:12
【问题描述】:

我将QPainterPath 与文本放在一起,然后我正在绘制它,首先是QPainter::strokePath,然后是QPainter::fillPath。但是,笔划会出现伪影,如图所示。我做错了什么/如何防止这种情况?我应该将其报告为错误吗?

【问题讨论】:

    标签: qt qpainter qpainterpath


    【解决方案1】:

    我发现下面的代码没有使用strokePathfillPath,而是在没有伪影的情况下工作,而且渲染速度更快:

    if(outlineEnabled) {
        p.setBrush(Qt::NoBrush);
        p.setPen(QPen(outlineColor, outlineWidth/scaleFactor, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
        for(const auto &polygon : path.toSubpathPolygons())
            p.drawPolygon(polygon, Qt::OddEvenFill);
    }
    
    p.setBrush(color);
    p.setPen(Qt::NoPen);
    for(const auto &polygon : path.toFillPolygons())
        p.drawPolygon(polygon, Qt::OddEvenFill);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-16
      • 2014-04-26
      • 2023-03-08
      • 2021-12-29
      • 1970-01-01
      • 2010-10-08
      • 2018-07-10
      • 1970-01-01
      相关资源
      最近更新 更多