Results 1 to 3 of 3

Thread: QGraphicsItem selection

  1. #1
    Join Date
    Aug 2008
    Posts
    134
    Thanks
    10
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsItem selection

    Hi,
    I have seen pressing Ctrl button and clicking on the item lead to select multiple items.
    Is there any way so that only one QGraphicsItem is selected???
    If I call setSelected(true) in constructor then created item's isSelected() returns true and even previously created item's isSelected() returns true. How can I avoid these????


    Thank you

  2. #2
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsItem selection

    means this one .. Qt::FocusPolicy .. ?

    the best way for u is
    void QGraphicsItem::installSceneEventFilter ( QGraphicsItem * filterItem )
    and try to restrict any event on other items while current one is selected
    Last edited by wagmare; 27th July 2009 at 11:34. Reason: sorry i refered Qt::FocusPolicy wrongly
    "Behind every great fortune lies a crime" - Balzac

  3. #3
    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: QGraphicsItem selection

    I would reimplement QGraphicsItem::itemChange() for your items and react on the QGraphicsItem::ItemSelectedHasChanged to notify the scene it should deselect all the other items. Care to read the note in ItemSelectedHasChanged docs.
    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. [SOLVED] QTreeView drawing selection with icons
    By Timewarp in forum Qt Programming
    Replies: 7
    Last Post: 7th February 2013, 07:52
  2. destruction of QGraphicsItem
    By killkolor in forum Qt Programming
    Replies: 2
    Last Post: 5th December 2009, 10:31
  3. Replies: 1
    Last Post: 18th November 2009, 23:21
  4. selection of QGraphicsItem
    By navi1084 in forum Qt Programming
    Replies: 6
    Last Post: 23rd July 2009, 06:33
  5. Replies: 1
    Last Post: 25th February 2009, 00:34

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.