QGraphicsLineItem line width
-
Hi ,
Can somebody explain how to draw a QGraphicsLineItem's line with a width of 1 pixel?
I have set the painter's pen width to 1p->setPen(QPen(QColor(213,164,83),1));
p->drawLine(line());but the line width is grater than 1.
If I draw line on a QLabel or QWidget paint methods it works ok
-
Hi,
line width is relative to the "distance" between the view and the scene. More you zoom, more the width grows. If you want the line to be always 1, independently from the "distance", you should set the pen width to 0.
Look at the QPen::setWidth documentation.
Tony.
-
Hi,
Thanks for suggestion but it seams I get the same display.
Anyway I have no zoom set (yet).
pen.setWidth(0);
p->setPen(pen);
p->drawLine(line());
!http://1.bp.blogspot.com/_8XPM3BE3B_E/TPSfDZLe7aI/AAAAAAAAAHs/FPpGulCw5V0/s1600/Untitled.png(Print)!On the ruler I get the correct display (1 pixel) and on the scene ...?!
-
[quote author="Doru" date="1291103107"]void GuideItem::paint( QPainter *p, const QStyleOptionGraphicsItem *option, QWidget * )
[/quote]Is GuideItem inherited from QGraphicsLineItem? If "yes" then why do you paint line yourself? Does call to QGraphicsLineItem::paint() produce the same result?