1
境界矩形の端に弧を描こうとしています。これはコントロールで拡大縮小したいので重要です。しかし、drawArc()
の引数としてboundingRect()
を使用すると、エッジが切り取られることになります。Qt5ペインタで円弧を正しく描く
QBrush brush(QColor("#007430"));
painter->setBrush(brush);
QPen pen;
pen.setStyle(Qt::SolidLine);
float lineWidth1 = 6.0;
pen.setWidthF(lineWidth1);
painter->setPen(pen);
painter->setRenderHint(QPainter::Antialiasing);
painter->drawArc(boundingRect(), 45*16, 270*16);
それが正常に動作させるために、私はそれぞれの側に小さなペン幅の1/2である長方形に渡す必要があります。 手作業による計算/調整なしでQTでこれを行うより直接的な方法はありますか?
QRectF arcRect(0 + lineWidth1/2,
0 + lineWidth1/2,
boundingRect().width() - lineWidth1,
boundingRect().height() - lineWidth1);
painter->drawArc(arcRect, 45*16, 270*16);