Results 1 to 4 of 4

Thread: Selecting QGraphicsItems

  1. #1
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Selecting QGraphicsItems

    I've turned RubberBand mode on in QGraphicsView containing an assortment of custom QGraphicsItems. When I draw a box around them, my understanding is that the items become selected, but there is no visual change in their appearance. I've set the itemIsSelectable flag on all the items, and added a line that checks isSelected() in the paint routine, but I'm not seeing any difference.

    Is there some other setting I have to adjust? I'm somewhat limited on time today and haven't had a chance to explore every possibility, but I don't see anything else in the QGraphicsView/Scene/Item framework that I can do to make this happen.

    Basically, the program currently allows users to change the classification of an item through a context menu, and I'd like to extend that ability to include classifying groups of items enclosed by the rubber band box.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Selecting QGraphicsItems

    I always use
    Qt Code:
    1. if (option->state & QStyle::State_Selected)
    2. //...
    To copy to clipboard, switch view to plain text mode 
    in the paint method. Did that work for you?

  3. #3
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Selecting QGraphicsItems

    I'll try it. I'm no longer at the machine where my code resides, so it'll have to wait 'til tomorrow.

    I was saying

    if (isSelected())
    // use a certain color for the outline
    else
    // use some other color for the outline

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Selecting QGraphicsItems

    OK, this seems to be working as expected. Not sure why the other approach using isSelected() didn't, but it's time to move on.

    Thanks.

Similar Threads

  1. Selecting a QLine
    By Paul Drummond in forum Qt Programming
    Replies: 6
    Last Post: 2nd September 2015, 16:30
  2. selecting that single character..
    By jajdoo in forum Newbie
    Replies: 1
    Last Post: 27th July 2010, 21:15
  3. QTreeWidgetItem, selecting and removing
    By Zergi in forum Newbie
    Replies: 4
    Last Post: 10th January 2008, 18:45
  4. QListWidget and selecting an item
    By invictus in forum Newbie
    Replies: 4
    Last Post: 19th June 2007, 11:59
  5. Selecting row in QTableView
    By teS in forum Newbie
    Replies: 1
    Last Post: 15th January 2006, 11:45

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.