1 Attachment(s)
Bordered Line/ Point or any closed Figure
Hi,
As for many days I was trying to get a line or point or any closed figure which will have borders around it. By use of QPainter with specific QPen or QBrush it is drawing (using drawLine, drawpoint, drawPolyline etc) only single color figure.
Is there any way to get closed figure with border around line. Attachment 12453
Re: Bordered Line/ Point or any closed Figure
Re: Bordered Line/ Point or any closed Figure
Quote:
Originally Posted by
Santosh Reddy
Use QPainterPath
Actually I searched for possibility of doing this but could find any way, even with QPainterPath. Can you please tell me how to use QPainterPath for the same?
Re: Bordered Line/ Point or any closed Figure
Not sure what exactly what you want to do, anyway here is an example to use QPainterPath.
Code:
{
public:
explicit MyWidget
(QWidget * parent
= 0)
protected:
{
const QRect rect
= event
->rect
();
const QPoint center
= rect.
center();
const int height = rect.height() / 4;
const int width = rect.width() / 4;
path.moveTo(center);
path.moveTo(center.x() , center.y() - height);
path.lineTo(center.x() + width , center.y() - height);
path.lineTo(center.x() + width , center.y());
path.lineTo(center.x() + width , center.y() + height);
path.closeSubpath();
painter.drawPath(path);
painter.
fillPath(path,
QBrush(Qt
::CrossPattern));
}
};
int main(int argc, char *argv[])
{
MyWidget widget;
widget.show();
return app.exec();
}