qpainterpath 平移(qpainterpath旋转)

qpainterpath 平移(qpainterpath旋转)void TestArcTo paintEvent QPaintEvent QRect rect span style color rgba 128 0 128 1 30 span

大家好,我是讯享网,很高兴认识大家。



void TestArcTo::paintEvent(QPaintEvent *) {
讯享网
讯享网QRect rect(</span><span style="color: rgba(128, 0, 128, 1)">30</span>, <span style="color: rgba(128, 0, 128, 1)">30</span>, <span style="color: rgba(128, 0, 128, 1)">200</span>, <span style="color: rgba(128, 0, 128, 1)">200</span><span style="color: rgba(0, 0, 0, 1)">); QPainter p(</span><span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">); p.setRenderHint(QPainter::Antialiasing); p.fillRect(rect, QColor(</span><span style="color: rgba(128, 0, 128, 1)">255</span>, <span style="color: rgba(128, 0, 128, 1)">255</span>, <span style="color: rgba(128, 0, 128, 1)">0</span><span style="color: rgba(0, 0, 0, 1)">)); </span><span style="color: rgba(0, 0, 255, 1)">int</span> cornerSize = <span style="color: rgba(128, 0, 128, 1)">50</span>; <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">调节圆角的大小</span> <span style="color: rgba(0, 0, 255, 1)">int</span> arcR = cornerSize/<span style="color: rgba(128, 0, 128, 1)">2</span><span style="color: rgba(0, 0, 0, 1)">; QPainterPath path; path.moveTo(rect.left() </span>+<span style="color: rgba(0, 0, 0, 1)"> arcR, rect.top()); path.arcTo(rect.left(), rect.top(), cornerSize, cornerSize, </span><span style="color: rgba(128, 0, 128, 1)">90.0f</span>, <span style="color: rgba(128, 0, 128, 1)">90.0f</span><span style="color: rgba(0, 0, 0, 1)">); path.lineTo(rect.left(), rect.bottom() </span>-<span style="color: rgba(0, 0, 0, 1)"> arcR); path.arcTo(rect.left(), rect.bottom() </span>- cornerSize, cornerSize, cornerSize, <span style="color: rgba(128, 0, 128, 1)">180.0f</span>, <span style="color: rgba(128, 0, 128, 1)">90.0f</span><span style="color: rgba(0, 0, 0, 1)">); path.lineTo(rect.right() </span>-<span style="color: rgba(0, 0, 0, 1)"> arcR, rect.bottom()); path.arcTo(rect.right() </span>- cornerSize, rect.bottom() - cornerSize, cornerSize, cornerSize, <span style="color: rgba(128, 0, 128, 1)">270.0f</span>, <span style="color: rgba(128, 0, 128, 1)">90.0f</span><span style="color: rgba(0, 0, 0, 1)">); path.lineTo(rect.right(), rect.top() </span>+<span style="color: rgba(0, 0, 0, 1)"> arcR); path.arcTo(rect.right() </span>- cornerSize, rect.top(), cornerSize, cornerSize, <span style="color: rgba(128, 0, 128, 1)">0.0f</span>, <span style="color: rgba(128, 0, 128, 1)">90.0f</span><span style="color: rgba(0, 0, 0, 1)">); p.fillPath(path, QBrush(QColor(</span><span style="color: rgba(128, 0, 128, 1)">122</span>, <span style="color: rgba(128, 0, 128, 1)">122</span>, <span style="color: rgba(128, 0, 128, 1)">122</span><span style="color: rgba(0, 0, 0, 1)">))); 
}

讯享网

小讯
上一篇 2025-04-28 10:15
下一篇 2025-04-18 15:12

相关推荐

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/196938.html