c++ - Qt: Custom QGraphicsItem not showing when boundingRect() center is out of view -



c++ - Qt: Custom QGraphicsItem not showing when boundingRect() center is out of view -

i'm making diagram (fluxogram) programme , days i'm stuck issue:

i have custom qgraphicsscene expands horizontally whenever place item it's rightmost area. problem custom arrows (they inherit qgraphicspathitem) disappear scene whenever it's boundingrect() center scrolled off view. everytime scene expands, both it's scenerect() , view's scenerect() updated well.

i've:

set ui->graphicsview->setviewportupdatemode(qgraphicsview::fullviewportupdate)

the item flags qgraphicsitem::itemignorestransformations , qgraphicsitem::itemsendsgeometrychanges, setactive(true) on item well, , everytime add together arrow scene phone call update(scenerect()) method. still, everytime scroll view, arrow's boundingrect() center moves away view, arrow disappears. if scroll , boundingrect() center enters view, arrow appears again.

can give me tip of might missing? i've been using qt's illustration project diagramscene reference, lot of code similar (the "press item toolbutton -> click on scene" relation insert items, way place arrows connect objects,...).

in meanwhile i'll seek create minimal running illustration can show issue is.

your arrow object inherits qgraphicspathitem, expect implements qgraphicsitem::shape function.

override shape function in arrow class, homecoming shape of item. this, along boundingrect used collision detection , detection of item on-screen.

in addition, before changing shape of item changing boundingrect, need phone call preparegeometrychange.

as docs state: -

prepares item geometry change. phone call function before changing bounding rect of item maintain qgraphicsscene's index date.

so, in arrow class, store qrectf called m_boundingrect , in constructor: -

preparegeometrychange(); m_boundingrect = qrectf(-x, -y, x*2, y*2);

then homecoming m_boundingrect in boundingrect() function.

if still issue, expect it's in qgraphicspainterpath that's causing problem, in case, can inherit qgraphicsitem , store qpainterpath draw in item's paint function , homecoming painter path in shape().

c++ qt qgraphicsitem qgraphicsscene

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -