Results 1 to 3 of 3

Thread: Appliation specific data to the QGraphicsScene items

  1. #1
    Join Date
    Feb 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Appliation specific data to the QGraphicsScene items

    I am using PyQt.

    I am adding QPolygonF to it and adding my own data to each class as:

    Qt Code:
    1. polygon.data = ownData
    To copy to clipboard, switch view to plain text mode 

    Python allows dynamic binding so I can do it. I later want to query for items that lie within the given rectangle using items() method and check the items in the returned list for "data" I get AttributeError. Does addPolygon() only draws and not stores the items?

  2. #2
    Join Date
    Mar 2010
    Location
    Heredia, Costa Rica
    Posts
    257
    Thanks
    24
    Thanked 17 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Appliation specific data to the QGraphicsScene items

    data() returns a pointer to the data stored in the vector. The pointer can be used to access and modify the items in the vector. This is the polygon data. If you want to store custom data at item level use:

    QVariant QGraphicsItem::data ( int key )

  3. #3
    Join Date
    Feb 2011
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Appliation specific data to the QGraphicsScene items

    In fact I found the solution. One cannot use the QPolygonF, but need to use QGraphicsPolygonItem which provides the data() method.

Similar Threads

  1. addRect doesn't plot specific data
    By penny in forum Qt Programming
    Replies: 2
    Last Post: 18th February 2011, 10:16
  2. Replies: 2
    Last Post: 5th September 2010, 14:06
  3. Replies: 1
    Last Post: 23rd January 2010, 22:04
  4. Context Menu for specific items in a Tree Widget
    By manekineko in forum Qt Programming
    Replies: 0
    Last Post: 16th November 2009, 01:46
  5. Replies: 8
    Last Post: 1st October 2009, 10:07

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.