qt - QGraphicsScene does not update immediately -



qt - QGraphicsScene does not update immediately -

i drawing ellipse in graphics scene. when ellipse tilted, portion of boundary not appear immediately. after re-size window or perform either zoom-in or zoom-out action in graphics scene, ellipse boundary updated , perfect shape required.

i have defined paint function ellipse as:

qpainterpath ellipse; ellipse.moveto(p1.x()+majradius, p1.y()); ellipse.arcto(boundingrect(), 0 , 360); qpen paintpen(qt::black); paintpen.setwidth(1); painter->setrenderhint(qpainter::antialiasing); painter->setpen(paintpen); painter->save(); painter->translate(p1.x(), p1.y()); painter->rotate(theta); painter->translate(-p1.x(), -p1.y()); painter->drawpath(ellipse); painter->restore();

the definition of bounding rectangle is:

return qrectf(p1.x()-majradius, p1.y()-minradius, 2*majradius, 2*minradius).normalized();

i have attached screenshot of 2 cases of ellipse:

how solve issue?

you didn't show of import code, think can guess problem.

when alter property of qgraphicsitem has impact on qgraphicsitem::boundingrect() should phone call qgraphicsitem::preparegeometrychange not not update. see documentation of qgraphicsitem::boundingrect.

second problem see have messed rotation-translation , bounding rectangle. seek rotate painter path not painter itself.

another issue can see saving , restoring painter in wrong meaner. saving should happen before perform alter on painter (in case before painter->setrenderhint(qpainter::antialiasing);) , restore state after painting of item completed (this ok).

qt qgraphicsscene

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -