本文整理汇总了C++中QPainterPath::arcTo方法的典型用法代码示例。如果您正苦于以下问题:C++ QPainterPath::arcTo方法的具体用法?C++ QPainterPath::arcTo怎么用?C++ QPainterPath::arcTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPainterPath
的用法示例。
在下文中一共展示了QPainterPath::arcTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createRotateArrow
static QPainterPath createRotateArrow()
{
const qreal arrowHeadPos = 12;
const qreal arrowHeadLength = 4.5;
const qreal arrowHeadWidth = 5;
const qreal bodyWidth = 1.5;
const qreal outerArcSize = arrowHeadPos + bodyWidth - arrowHeadLength;
const qreal innerArcSize = arrowHeadPos - bodyWidth - arrowHeadLength;
QPainterPath path;
path.moveTo(arrowHeadPos, 0);
path.lineTo(arrowHeadPos + arrowHeadWidth, arrowHeadLength);
path.lineTo(arrowHeadPos + bodyWidth, arrowHeadLength);
path.arcTo(QRectF(arrowHeadLength - outerArcSize,
arrowHeadLength - outerArcSize,
outerArcSize * 2,
outerArcSize * 2),
0, -90);
path.lineTo(arrowHeadLength, arrowHeadPos + arrowHeadWidth);
path.lineTo(0, arrowHeadPos);
path.lineTo(arrowHeadLength, arrowHeadPos - arrowHeadWidth);
path.lineTo(arrowHeadLength, arrowHeadPos - bodyWidth);
path.arcTo(QRectF(arrowHeadLength - innerArcSize,
arrowHeadLength - innerArcSize,
innerArcSize * 2,
innerArcSize * 2),
-90, 90);
path.lineTo(arrowHeadPos - arrowHeadWidth, arrowHeadLength);
path.closeSubpath();
return path;
}
示例2: switch
QPainterPath
Shapes::unAboveBelow(const QRectF &bound, Style style)
{
_S(6) _S(3) _S(4)
QPainterPath path;
switch (style)
{
case Square:
case LasseKongo:
path.addRect(bound.adjusted(0, s4, -2*s3, -s4));
path.addRect(bound.adjusted(2*s3, s4, 0, -s4));
break;
default:
case Round:
case TheRob:
QRectF rect = bound.adjusted(0,0,-s6, 0);
path.moveTo(rect.center());
path.arcTo(rect, 90, 180);
path.closeSubpath();
rect.translate(s6,0);
path.moveTo(rect.center());
path.arcTo(rect, -90, 180);
path.closeSubpath();
break;
}
return path;
}
示例3: drawHoverRect
void CustomStyle::drawHoverRect(QPainter *painter, const QRect &rect) const
{
/* double h = r.height();
double h2 = r.height() / 2.0;
QPainterPath path;
path.addRect(r.x() + h2, r.y() + 0, r.width() - h2 * 2, r.height());
path.addEllipse(r.x(), r.y(), h, h);
path.addEllipse(r.x() + r.width() - h, r.y(), h, h);
path.setFillRule(Qt::WindingFill);
painter->setPen(Qt::NoPen);
painter->setBrush(QColor(191, 215, 191));
painter->setRenderHint(QPainter::Antialiasing);
painter->drawPath(path);*/
int radius = qMin(rect.width(), rect.height()) / 2;
int diam = 2 * radius;
int x1, y1, x2, y2;
rect.getCoords(&x1, &y1, &x2, &y2);
QPainterPath path;
QColor color;
color = mergedColors(QColor(0x06, 0x4C, 0xA4), QColor(0xd6, 0xd6, 0xd6));
QPen pen(color, 4);
painter->setPen(pen);
path.moveTo(x2, y1 + radius);
path.arcTo(QRect(x2 - diam, y1, diam, diam), 0.0, +90.0);
path.lineTo(x1 + radius, y1);
path.arcTo(QRect(x1, y1, diam, diam), 90.0, +90.0);
path.lineTo(x1, y2 - radius);
path.arcTo(QRect(x1, y2 - diam, diam, diam), 180.0, +90.0);
path.lineTo(x1 + radius, y2);
path.arcTo(QRect(x2 - diam, y2 - diam, diam, diam), 270.0, +90.0);
painter->drawPath(path);
}
示例4: testArcMoveTo
void tst_QPainterPath::testArcMoveTo()
{
QFETCH(QRectF, rect);
QFETCH(qreal, angle);
QPainterPath path;
path.arcMoveTo(rect, angle);
path.arcTo(rect, angle, 30);
path.arcTo(rect, angle + 30, 30);
QPointF pos = path.elementAt(0);
QVERIFY((path.elementCount()-1) % 3 == 0);
qreal x_radius = rect.width() / 2.0;
qreal y_radius = rect.height() / 2.0;
QPointF shouldBe = rect.center()
+ QPointF(x_radius * cos(ANGLE(angle)), -y_radius * sin(ANGLE(angle)));
qreal iw = 1 / rect.width();
qreal ih = 1 / rect.height();
QVERIFY(pathFuzzyCompare(pos.x() * iw, shouldBe.x() * iw));
QVERIFY(pathFuzzyCompare(pos.y() * ih, shouldBe.y() * ih));
}
示例5: ri
//------------------------------------------------------------------------------
void
Canvas::DrawAnnulus(int x, int y,
unsigned inner_r, unsigned outer_r,
Angle start, Angle end)
{
QPainterPath p;
QRectF ri(x - inner_r, y - inner_r, 2 * inner_r, 2 * inner_r);
QRectF ro(x - outer_r, y - outer_r, 2 * outer_r, 2 * outer_r);
// Draw the inner radius of the annulus.
p.arcMoveTo(ri, start.Degrees());
p.arcTo(ri, start.Degrees(), end.Degrees() - start.Degrees());
if (start != end)
{ // Only draw the end caps when needed.
// The currentPosition() will be at the end of the inner circle. Draw
// one side of the annulus.
// \todo This doesn't work because Angle(360) != Angle(0)!
double xx = (outer_r - inner_r) * cos(end.Radians()) +
p.currentPosition().rx();
double yy = (outer_r - inner_r) * -sin(end.Radians()) +
p.currentPosition().ry();
p.lineTo(xx, yy);
}
else
p.arcMoveTo(ro, end.Degrees()); // Set up for the outer circle.
// The currentPosition() will be at the 'end' of the outer circle. Draw the
// outer to the start.
p.arcTo(ro, end.Degrees(), start.Degrees() - end.Degrees());
if (start != end)
{// And close it off to finish up.
p.closeSubpath();
}
this->pushObject(p, this->pen(), this->brush());
}
示例6: getBottomCornerPath
QPainterPath DArrowRectangle::getBottomCornerPath()
{
qreal delta = shadowBlurRadius() + shadowDistance();
QRect rect = this->rect().marginsRemoved(QMargins(delta, delta, delta, delta));
QPoint cornerPoint(rect.x() + (m_arrowX > 0 ? m_arrowX : rect.width() / 2), rect.y() + rect.height());
QPoint topLeft(rect.x(), rect.y());
QPoint topRight(rect.x() + rect.width(), rect.y());
QPoint bottomRight(rect.x() + rect.width(), rect.y() + rect.height() - m_arrowHeight);
QPoint bottomLeft(rect.x(), rect.y() + rect.height() - m_arrowHeight);
int radius = this->m_radius > (rect.height() / 2 - m_arrowHeight) ? rect.height() / 2 -m_arrowHeight : this->m_radius;
QPainterPath border;
border.moveTo(topLeft.x() + radius, topLeft.y());
border.lineTo(topRight.x() - radius, topRight.y());
border.arcTo(topRight.x() - 2 * radius, topRight.y(), 2 * radius, 2 * radius, 90, -90);
border.lineTo(bottomRight.x(), bottomRight.y() - radius);
border.arcTo(bottomRight.x() - 2 * radius, bottomRight.y() - 2 * radius, 2 * radius, 2 * radius, 0, -90);
border.lineTo(cornerPoint.x() + m_arrowWidth / 2, cornerPoint.y() - m_arrowHeight);
border.lineTo(cornerPoint);
border.lineTo(cornerPoint.x() - m_arrowWidth / 2, cornerPoint.y() - m_arrowHeight);
border.lineTo(bottomLeft.x() + radius, bottomLeft.y());
border.arcTo(bottomLeft.x(), bottomLeft.y() - 2 * radius, 2 * radius, 2 * radius, -90, -90);
border.lineTo(topLeft.x(), topLeft.y() + radius);
border.arcTo(topLeft.x(), topLeft.y(), 2 * radius, 2 * radius, 180, -90);
return border;
}
示例7: drawBg
void SwitchButton::drawBg(QPainter *painter)
{
painter->save();
painter->setPen(Qt::NoPen);
if (!checked) {
painter->setBrush(bgColorOff);
} else {
painter->setBrush(bgColorOn);
}
if (buttonStyle == ButtonStyle_Rect) {
painter->drawRoundedRect(rect(), rectRadius, rectRadius);
} else if (buttonStyle == ButtonStyle_CircleIn) {
QRect rect(0, 0, width(), height());
//半径为高度的一半
int radius = qMin(rect.width(), rect.height()) / 2;
//圆的宽度为高度
int circleWidth = radius * 2;
QPainterPath path;
path.moveTo(radius, rect.left());
path.arcTo(QRectF(rect.left(), rect.top(), circleWidth, circleWidth), 90, 180);
path.lineTo(rect.width() - radius, rect.height());
path.arcTo(QRectF(rect.width() - rect.height(), rect.top(), circleWidth, circleWidth), 270, 180);
path.lineTo(radius, rect.top());
painter->drawPath(path);
} else if (buttonStyle == ButtonStyle_CircleOut) {
QRect rect(height() / 2, space, width() - height(), height() - space * 2);
painter->drawRoundedRect(rect, rectRadius, rectRadius);
}
painter->restore();
}
示例8: paintEvent
void QuickSwitchButton::paintEvent(QPaintEvent *e)
{
if (m_selected && m_showBackground)
{
const QRect r = rect();
const int radius = 6;
const int margin_bottom = 5;
QPainterPath path;
path.moveTo(0, 0);
path.arcTo(QRectF(QPointF(-radius, 0), QPointF(radius, radius * 2)), 90, -90);
path.lineTo(radius, r.bottom() - margin_bottom - radius * 2);
path.arcTo(QRectF(QPointF(radius, r.bottom() - margin_bottom - radius * 2), QPointF(radius * 3, r.bottom() - margin_bottom)), 180, 90);
path.lineTo(r.right() - radius * 2, r.bottom() - margin_bottom);
path.arcTo(QRectF(QPointF(r.right() - radius * 3, r.bottom() - margin_bottom - radius * 2), QPointF(r.right() - radius, r.bottom() - margin_bottom)), 270, 90);
path.lineTo(r.right() - radius, radius);
path.arcTo(QRectF(QPointF(r.right() - radius, 0), QPointF(r.right() + radius, radius * 2)), 180, -90);
path.closeSubpath();
QPainter painter(this);
painter.setPen(Qt::transparent);
painter.setBrush(QColor(255, 255, 255, 255 * .2));
painter.setRenderHint(QPainter::Antialiasing);
painter.drawPath(path);
}
QLabel::paintEvent(e);
}
示例9: getRectanglePath
QPainterPath BoxStyle::getRectanglePath(qreal x, qreal y, int width, int height) const
{
QPainterPath path;
int radius = cornerRadius_;
if (radius > width/2) radius = width/2;
if (radius > height/2) radius = height/2;
path.moveTo(width + x, radius + y);
if ( corner_ == CornerType::RightAngle ) path.lineTo(width + x, y);
else if ( corner_ == CornerType::Cut ) path.lineTo(width + x - radius, y);
else path.arcTo(width - 2 * radius + x, y, radius * 2, radius * 2, 0.0, 90.0);
path.lineTo(radius + x, y);
if ( corner_ == CornerType::RightAngle ) path.lineTo(x, y);
else if ( corner_ == CornerType::Cut ) path.lineTo(x, radius + y);
else path.arcTo(x, y, radius * 2, radius * 2, 90.0, 90.0);
path.lineTo(x, height - radius + y);
if ( corner_ == CornerType::RightAngle ) path.lineTo(x, height + y);
else if ( corner_ == CornerType::Cut ) path.lineTo(x + radius, height + y);
else path.arcTo(x, height - 2 * radius + y, radius * 2, radius * 2, 180.0, 90.0);
path.lineTo(width - radius + x, height + y);
if ( corner_ == CornerType::RightAngle ) path.lineTo(width + x, height + y);
else if ( corner_ == CornerType::Cut ) path.lineTo(x + width, height - radius + y);
else path.arcTo(width - 2 * radius + x, height - 2 * radius + y, radius * 2, radius * 2, 270.0, 90.0);
path.closeSubpath();
return path;
}
示例10: hingeShape
QPainterPath UBGraphicsCompass::hingeShape() const
{
QPainterPath path;
path.moveTo(hingeRect().left() + 4, hingeRect().top());
path.lineTo(hingeRect().right() - 4, hingeRect().top());
path.arcTo(
hingeRect().right() - 8,
hingeRect().top(),
8, 8,
90, -90);
path.lineTo(hingeRect().right(), hingeRect().bottom() - 4);
path.arcTo(
hingeRect().right() - 8,
hingeRect().bottom() - 8,
8, 8,
0, -90);
path.lineTo(hingeRect().left() + 4, hingeRect().bottom());
path.arcTo(
hingeRect().left(),
hingeRect().bottom() - 8,
8, 8,
-90, -90);
path.lineTo(hingeRect().left(), hingeRect().top() + 4);
path.arcTo(
hingeRect().left(),
hingeRect().top(),
8, 8,
-180, -90);
path.closeSubpath();
return path;
}
示例11: createArrow
static QPainterPath createArrow()
{
const qreal arrowHeadPos = 10;
const qreal arrowHeadLength = 4;
const qreal arrowHeadWidth = 4;
const qreal arcWidth = 2;
const qreal outerArcSize = arrowHeadPos + arcWidth - arrowHeadLength;
const qreal innerArcSize = arrowHeadPos - arcWidth - arrowHeadLength;
QPainterPath path;
path.moveTo(arrowHeadPos, 0);
path.lineTo(arrowHeadPos + arrowHeadWidth, arrowHeadLength);
path.lineTo(arrowHeadPos + arcWidth, arrowHeadLength);
path.arcTo(QRectF(arrowHeadLength - outerArcSize,
arrowHeadLength - outerArcSize,
outerArcSize * 2,
outerArcSize * 2),
0, -90);
path.lineTo(arrowHeadLength, arrowHeadPos + arrowHeadWidth);
path.lineTo(0, arrowHeadPos);
path.lineTo(arrowHeadLength, arrowHeadPos - arrowHeadWidth);
path.lineTo(arrowHeadLength, arrowHeadPos - arcWidth);
path.arcTo(QRectF(arrowHeadLength - innerArcSize,
arrowHeadLength - innerArcSize,
innerArcSize * 2,
innerArcSize * 2),
-90, 90);
path.lineTo(arrowHeadPos - arrowHeadWidth, arrowHeadLength);
path.closeSubpath();
path.translate(-3, -3);
return path;
}
示例12: roundedRect
QPainterPath roundedRect(const QRect& rc, int nRadius)
{
QPainterPath path;
// Diameter
qreal d = nRadius * 2 + 1;
if (rc.width() < d || rc.height() < d)
return path;
qreal x0 = rc.left() + 0.5;
qreal x3 = rc.right() - 1 + 0.5;
qreal y0 = rc.top() + 0.5;
qreal y3 = rc.bottom() - 1 + 0.5;
QRectF rcTR(x3 - d, y0, d, d);
QRectF rcBR(x3 - d, y3 - d, d, d);
QRectF rcBL(x0, y3 - d, d, d);
QRectF rcTL(x0, y0, d, d);
path.moveTo(rcTR.topLeft());
path.arcTo(rcTR, 90, -90);
path.arcTo(rcBR, 0, -90);
path.arcTo(rcBL, -90, -90);
path.arcTo(rcTL, -180, -90);
path.closeSubpath();
return path;
}
示例13: drawCurveRectangle
void KeyboardLayoutWidget::drawCurveRectangle(QPainter* painter, bool filled, QColor color, int x, int y, int width, int height, double radius)
{
double x1, y1;
if (!width || !height)
return;
x1 = x + width;
y1 = y + height;
radius = qMin (radius, (double) qMin (width / 2, height / 2));
QPainterPath path;
path.moveTo(x, y + radius);
path.arcTo(x, y, 2 * radius, 2 * radius, 180, -90);
path.lineTo (x1 - radius, y);
path.arcTo (x1 - 2 * radius, y, 2 * radius, 2 * radius, 90, - 90);
path.lineTo (x1, y1 - radius);
path.arcTo (x1 - 2 * radius, y1 - 2 * radius, 2 * radius, 2 * radius, 0, -90);
path.lineTo (x + radius, y1);
path.arcTo (x , y1 - 2 * radius, 2 * radius, 2 * radius, -90, -90);
path.closeSubpath();
painter->save();
if (filled) {
QBrush brush(color);
painter->fillPath (path, brush);
}
else {
painter->setPen(color);
painter->drawPath(path);
}
painter->restore();
}
示例14: paintMeshElToBeHigh
void EditorArea::paintMeshElToBeHigh(QPainter &painter)
{
qreal radius = size2screen(8);
float fontSize = size2screen(12);
qreal width = radius * 2;
qreal height = radius * 2;
QPainterPath path;
QPainterPath text;
QPainterPath circle;
path.arcTo(QRectF(-radius, -radius, width, height), 0, 360);
text.addText(-radius / 2.0, radius / 2.0, QFont("Arial", fontSize), meshElsType.value(meshElToBeHigh));
circle.arcTo(QRectF(-radius * 3 / 2, -radius * 3 / 2, width * 3 / 2, height * 3 / 2), 0, 360);
path.translate(meshElsPos.value(meshElToBeHigh));
text.translate(meshElsPos.value(meshElToBeHigh));
circle.translate(meshElsPos.value(meshElToBeHigh));
painter.setPen(Qt::NoPen);
painter.setBrush(Qt::magenta);
painter.drawPath(circle);
painter.setBrush(Qt::darkCyan);
painter.drawPath(path);
painter.setPen(Qt::yellow);
painter.setBrush(Qt::yellow);
painter.drawPath(text);
}
示例15: paintEvent
void Widget::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter;
QPainterPath path;
QPen pen(Qt::darkGray);
painter.begin(this);
pen.setWidth(3);
pen.setCapStyle(Qt::RoundCap);
pen.setJoinStyle(Qt::RoundJoin);
painter.setBrush(Qt::darkGray);
painter.drawRect(ui->crossBlock->x(),ui->crossBlock->y(),ui->crossBlock->width(),ui->crossBlock->height());
pen.setColor(Qt::black);
painter.setPen(pen);
painter.drawLine(ui->crossBlock->x()+1,ui->crossBlock->y()+1,ui->crossBlock->x()+ui->crossBlock->width(),ui->crossBlock->y()+ui->crossBlock->height());
painter.drawLine(ui->crossBlock->x()+1,ui->crossBlock->y()+ui->crossBlock->height(),ui->crossBlock->x()+ui->crossBlock->width(),ui->crossBlock->y()+1);
pen.setColor(Qt::yellow);
painter.setPen(pen);
int mca_x = ui->mcaImage->x();
int mca_y = ui->mcaImage->y();
int mcb_x = ui->mcbImage->x();
int mcb_y = ui->mcbImage->y();
int mc_width = ui->mcaImage->width();
int mc_height = ui->mcaImage->height();
painter.setBrush(Qt::NoBrush);
// painter.drawRoundedRect(mca_x,mca_y,mc_width,mc_height,5,5);
// painter.drawRoundedRect(mcb_x,mcb_y,mc_width,mc_height,5,5);
painter.drawRect(mca_x,mca_y,mc_width,mc_height);
painter.drawRect(mcb_x,mcb_y,mc_width,mc_height);
// painter.setPen(Qt::NoPen);
painter.setBrush(Qt::NoBrush);
painter.eraseRect(mca_x-5,mca_y-5,mc_width*0.1,mc_height*1.2);
painter.eraseRect(mcb_x+mc_width*0.9+5,mcb_y-5,mc_width*0.1+2,mc_height*1.2);
path.moveTo(mca_x+mc_width*0.1,mca_y);
path.arcTo(QRectF(mca_x+mc_width*0.1-mc_height/2,mca_y,mc_height,mc_height),90,180);
pen.setColor(Qt::yellow);
painter.setPen(pen);
painter.drawPath(path);
path.moveTo(mcb_x+mc_width*0.8,mcb_y);
path.arcTo(QRectF(mcb_x+mc_width*0.9-mc_height/2,mcb_y,mc_height,mc_height),90,-180);
painter.drawPath(path);
int smallRectWidth =mc_width/6;
int smallRectHeight= mc_height/4;
painter.setBrush(Qt::yellow);
painter.drawRect(mca_x+mc_width*0.3-smallRectWidth,mca_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight);
painter.drawRect(mca_x+mc_width-smallRectWidth*0.5-smallRectWidth,mca_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight);
painter.drawRect(mca_x+mc_width*0.3-smallRectWidth,mca_y+mc_height-smallRectHeight*1.3,smallRectWidth,smallRectHeight);
painter.drawRect(mca_x+mc_width-smallRectWidth*0.5-smallRectWidth,mca_y+mc_height-smallRectHeight*1.3,smallRectWidth,smallRectHeight);
painter.drawRect(QRectF(mcb_x+smallRectWidth*0.5,mcb_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight));
painter.drawRect(QRectF(mcb_x+smallRectWidth*0.5,mcb_y+mc_height-smallRectHeight*0.3-smallRectHeight,smallRectWidth,smallRectHeight));
painter.drawRect(QRectF(mcb_x+mc_width*0.7,mcb_y+smallRectHeight*0.3,smallRectWidth,smallRectHeight));
painter.drawRect(QRectF(mcb_x+mc_width*0.7,mcb_y+mc_height-smallRectHeight*0.3-smallRectHeight,smallRectWidth,smallRectHeight));
QSize Size = painter.fontMetrics().size(Qt::TextSingleLine, str);
painter.setPen(Qt::white);
painter.drawText(QPointF(mca_x+mc_width/2-Size.width()/2,mca_y+mc_height/2+Size.height()/2),str);
painter.drawText(QPointF(mcb_x+mc_width/2-Size.width()/2,mcb_y+mc_height/2+Size.height()/2),str);
painter.end();
}