Results 1 to 2 of 2

Thread: Saving QGraphics Scene items

  1. #1
    Join Date
    Mar 2012
    Posts
    14
    Thanks
    1
    Platforms
    Windows

    Default Saving QGraphics Scene items

    Hi guys,

    I have a bunch of QGraphicsTextItems, QGraphicsLineItems added to the scene..and i am trying to do a save/load function

    What i did now was creating 2 different QList specifically for textItems and lineItems..

    So if there are new item type, i will create a new QList specifically for them..

    When i save the item, i have to do a for loop for each QList, and can be quite tedious if more new item type..

    Is there any more efficient method like creating only 1 container to store all the objects? and how do i differentiate the different type of objects when they are called in the same container?

    Thanks...

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Saving QGraphics Scene items

    All the objects are QGraphicsItems so you could use a single container of QGraphicsItem*. You be able to distinguish them by their QGraphicsItem::type() and using qgraphicsitem_cast

Similar Threads

  1. Items in QGraphics View not starting from the top.
    By penny in forum Qt Programming
    Replies: 3
    Last Post: 1st April 2011, 13:10
  2. Infinite (circular) QGraphics Scene
    By maitai in forum Qt Programming
    Replies: 10
    Last Post: 27th March 2011, 15:23
  3. QGraphics View Scene performance with polylines
    By iampowerslave in forum Qt Programming
    Replies: 0
    Last Post: 15th November 2010, 17:03
  4. Saving a FULLY rendered QWidget on a graphics scene
    By technoViking in forum Qt Programming
    Replies: 7
    Last Post: 25th October 2010, 22:47
  5. MouseEvent in QGraphics Scene?
    By fanatos in forum Newbie
    Replies: 1
    Last Post: 9th September 2010, 17:39

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.