c++ - Smoothing an inclined line -




i can't find proper way draw smooth inclined line without having over-pixelated in qt qpainterpath object.

note know doesn't make sense draw path in paintevent function, put there sake of simplicity. i'm trying draw line directly in central widget.

hereafter snippet of code:

void myobject::paintevent(qpaintevent *) {     qpainterpath apath;     apath.moveto(40.0, 60.0); //random values try     apath.lineto(254, 354.0);      qpainter painter(this);     painter.setpen(qpen(qcolor(20, 20, 200), 10, qt::solidline));     painter.drawpath(apath); } 

and here result get:

enter image description here

it's awful! beautiful lines can draw horizontal, vertical or 45° inclined ones...

if looking drawing quality, qt documentation provides illustrative example (5.x version) of use of render quality flags. generally, can use flags specified here (5.x version), , set them using qpainter::setrenderhint() (5.x version) function. see if able achieve desired quality using methods. code, you'd looking like

qpainter painter(this); painter.setrenderhint(qpainter::smoothpixmaptransform, true); painter.setrenderhint(qpainter::highqualityantialiasing, true); painter.setpen(qpen(qcolor(20, 20, 200), 10, qt::solidline)); painter.drawpath(apath); 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -