View Full Version : Who can draw this Area with QPainter?
mehrdadsilver
13th July 2013, 11:06
9284
how can draw this are with QPainter?
I used two pie with composite mode but i wasn't success :(((
please help me
Santosh Reddy
13th July 2013, 12:22
Try this
class Painter : public QWidget
{
public:
explicit Painter(QWidget * parent = 0) : QWidget(parent) { }
QSize sizeHint(void) const { return QSize(500, 500); }
protected:
void paintEvent(QPaintEvent * event)
{
const int arkWidth = 40;
const QRect & rect = event->rect();
const int side = qMin(rect.height(), rect.width());
if(side < (arkWidth * 2))
return;
QPainter painter(this);
QPen pen = painter.pen();
pen.setColor(Qt::darkBlue);
pen.setWidth(arkWidth);
painter.setPen(pen);
const int margin = pen.width();
QRect r(0, 0, side, side);
r.adjust(0, 0, -margin, -margin);
r.moveCenter(rect.center());
const int start = 20;
const int end = 180 - start * 2;
painter.drawArc(r, start * 16, end * 16);
}
};
mehrdadsilver
14th July 2013, 06:54
tnx Santosh , but i want to draw width of area dynamically with 500 pixel to 800 pixel Arc width and with these the area is not suitable :((
wysota
14th July 2013, 07:35
Use clipping to obtain the effect you want. Alternatively you can probably obtain a similar effect using QPainterPath.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.