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 ...?!
-
void GuideItem::paint( QPainter *p, const QStyleOptionGraphicsItem *option, QWidget * )
How can I modify this aliasing feature/setting? -
[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?
-
Yes , it produces the same result.
I paint it myself because I want to modify line color when selected. -
I did'n succeed with render hints.
Can this problem appear because it is a graphic item?