PDA

View Full Version : Smooth lines in QGraphicsView



JaRo999
25th September 2009, 10:40
Hi, how can I draw lines with smooth edges in QGraphicsView? I have strait dash line with 6px width and it looks really sharp and bad.

yogeshgokul
25th September 2009, 11:13
You need to change :
Qt::PenCapStyle
Qt::PenJoinStyle

burnttoy
25th September 2009, 14:23
If you mean the angled line looks "jagged" when drawn at an angle you'll need to turn on "antialiasing" in the QGraphicsView e.g.


graphicsView->setRenderHints(QPainter::Antialiasing);

Matthew.

JaRo999
27th September 2009, 14:35
Thank You both fot replies. Yogeshgokul - I was using that options already before I've wrote the post. Unfortunately they are not the way for "transition effect" between line and background. Burnttoy's code did the trick, however now some lines that should be black are gray - another problem to solve for the future :)

wysota
27th September 2009, 15:38
Burnttoy's code did the trick, however now some lines that should be black are gray - another problem to solve for the future :)

That's the way antialiasing works - it blurs the edges of the lines so if you have a black line with thickness of "1" it will become a black line with a thickness of "1" surrounded by two gray lines with a thickness of "1" each resulting in a gray line with a thickness of "3". It's either that or aliased lines.