Results 1 to 2 of 2

Thread: how to prevent child QGraphicItem from picking when calling items(path)?

  1. #1
    Join Date
    Apr 2012
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default how to prevent child QGraphicItem from picking when calling items(path)?

    I am implementing picking by calling scene.items(path) where path is a small circle around the pointer. I reimplement shape() to return concentric paths around the true shape, in other words, I am picking only the edge of items.

    I have a FramedText class, a QGraphicsItemGroup comprising a rect and text items. I want it to pick by the frame, and not by the text. Is there a way to prevent an item from picking, other than by reimplementing shape() to return a null path?

    I have reimplemented shape() for the group to return concentric squarish rings around the edge of the child rect. When the pointer is inside, the group shape() is called, and does not pick, but Qt also calls the child rect shape() , and since I have not reimplemented the rect shape() it does the default, returning the bounding rect, and that does pick. I suppose I just need to reimplement the child rect shape() to return a null path. But is seems ugly to have special classes for non-picking items.

    More generally, think of a group as a symbol, in the sense that it comprises many items, but you only want to pick by certain of the items, say the edge of the symbol, or the center of the symbol, or the opaque items of the symbol. Is there a simple way to keep Qt from traversing all the children of a group for the items(path) method?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to prevent child QGraphicItem from picking when calling items(path)?

    The simplest solution seems to be to have a list of ignored items and when you traverse the collission list, simply skip items from the ignored list.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Getting Child Items from QStandardItemModel
    By nikhilqt in forum Qt Programming
    Replies: 4
    Last Post: 4th June 2013, 16:10
  2. Replies: 2
    Last Post: 2nd July 2012, 13:54
  3. Child items are lost on drop
    By justin123 in forum Qt Programming
    Replies: 1
    Last Post: 30th May 2012, 13:55
  4. Replies: 1
    Last Post: 14th January 2012, 01:33
  5. Replies: 1
    Last Post: 6th September 2008, 00:54

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.