Re: Draw line with border
What about setStyleSheet("border: 1px black;"); ?
Re: Draw line with border
How can I do that?
What about speed in this case?
I need very fast drawing.
Re: Draw line with border
Hello,
You cannot draw a single line with borders. you can draw a rect with pen (which will be the border color) and brush (brush is the fill color of the rect).
Code:
painter->setPen(Qt::red); // rect will have a border of red color
painter
->setBrush
(QBrush(Qt
::black));
// rect will be filled with black colorpainter->drawRect(this->rect());
Re: Draw line with border
ehhm ... how can I draw a rectangle with angle? for example, line (10,10) - (50,50)?
and anyway, with rectangle I cannot draw miltiline analog.
P.S. I need it to draw roads in my map app.
Re: Draw line with border
Draw a QPainterPath. It can have both the outline and fill. QPainterPathStroker can come in handy.
Re: Draw line with border
Quote:
Originally Posted by
folibis
ehhm ... how can I draw a rectangle with angle? for example, line (10,10) - (50,50)?
QPainter::rotate()
Quote:
and anyway, with rectangle I cannot draw miltiline analog.
:confused:
1 Attachment(s)
Re: Draw line with border
Ok, in attached image I described what exactly I need.
And the code how I do it now:
Code:
pen.setCapStyle(Qt::RoundCap);
pen.setJoinStyle(Qt::RoundJoin);
pen.setColor(qRgb(201,199,182));
pen.setWidth(14);
painter.setPen(pen);
painter.drawPolyline(line1,4);
painter.drawPolyline(line2,4);
pen.setColor(qRgb(237,234,200));
pen.setWidth(10);
painter.setPen(pen);
painter.drawPolyline(line1,4);
painter.drawPolyline(line2,4);
I was not successful with QPainterPathStroker and QPainterPath at all. It just draw closed lines and I really don't know how to use it.
Rectangles ... ok guys, may be you use thermonuclear anisotropic grasper to eat spaghetti :D I just use a fork for that.
It seems too confusing to me to draw a rectangle and rotate it when you need just line )))
And anyway, it will be a bit problematic to connect one this "line" to others.
As I understand it is impossible to draw line with border in Qt now and it is very frustrating to me.
So I'll continue to use my method.
Thanks to all who responded!