Results 1 to 2 of 2

Thread: Custom QGraphicsItem not showing when boundingRect() center is out of view

  1. #1
    Join Date
    Oct 2014
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Custom QGraphicsItem not showing when boundingRect() center is out of view

    Hello.

    I'm making a Diagram (Fluxogram) program and for days I'm stuck with this issue:

    I have a custom QGraphicsScene that expands horizontally whenever I place an item to it's rightmost area. The problem is that my custom arrows (they inherit QGraphicsPathItem) disappear from the scene whenever it's boundingRect() center is scrolled off the view. Everytime the scene expands, both it's sceneRect() and the view's sceneRect() are updated as well. I've set ui->graphicsView->setViewportUpdateMode(QGraphicsView::FullViewport Update), the item flags QGraphicsItem::ItemIgnoresTransformations and QGraphicsItem::ItemSendsGeometryChanges, setActive(true) on the item as well, and everytime I add an arrow to the scene i call the update(sceneRect()) method. Still, everytime I scroll the view, as soon as the arrow's boundingRect() center moves away from the view, all the arrow disappears. If I scroll back and the boundingRect() center enters the view, all the arrow appears again.

    Can someone give me a tip of what I might be missing? I've been using Qt's example project diagramscene as reference, so a lot of my code is similar (the "press item toolButton -> click on the scene" relation to insert items, the way they place the arrows to connect the objects,...).

    Here's a minimal running example that can show what my issue is (there's a lot of code so I'll just paste the pastebin links, I don't know if I can use it here, so please let me know if it's not how it should be done, it's just that there's a lot of coding to determine positioning and readjustment of the scene):

    Header files: pastebin.com/43Vzkrkq ;
    C++ files: pastebin.com/aLuE5Yg4 ;
    UI file: pastebin.com/1mHWL0hG

    Thanks in advance

  2. #2
    Join Date
    Oct 2014
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Custom QGraphicsItem not showing when boundingRect() center is out of view

    Problem solved, changed inheritance of Arrow from QGraphicsPathItem to QGraphicsItem, and added shape() method (I think I didn't forget anything else).

Similar Threads

  1. hoverover for boundingrect qgraphicsitem
    By rogerholmes in forum Newbie
    Replies: 4
    Last Post: 11th January 2010, 21:47
  2. Updating the boundingRect of a QGraphicsItem
    By robin2000 in forum Qt Programming
    Replies: 4
    Last Post: 14th August 2009, 09:47
  3. QGraphicsItem force boundingRect
    By bunjee in forum Qt Programming
    Replies: 0
    Last Post: 27th September 2008, 17:49
  4. QGraphicsItem -> boundingRect()
    By harakiri in forum Qt Programming
    Replies: 4
    Last Post: 6th March 2008, 16:02
  5. Doubt in QGraphicsItem::boundingRect()
    By Gopala Krishna in forum Qt Programming
    Replies: 3
    Last Post: 22nd March 2007, 15:57

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.