Results 1 to 3 of 3

Thread: QGraphicsItem selection rectangle

  1. #1
    Join Date
    Mar 2010
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsItem selection rectangle

    Hi,
    I have some strange problems, can't figure out why when my QGraphicsItem got selection there's no selection rectangle (this dashed rectangle). Is there any way to turn it on after item get selection and off when lose selection? Or i have to draw this rectangle by my own in some paint event or sth?
    Other question, i didn't find any class or built-in solution to resize QGraphicsItem with black dot in the corners of selection rectangle, what is the best way to do it?

    ithinkso

  2. #2
    Join Date
    Jan 2012
    Location
    Dortmund, Germany
    Posts
    159
    Qt products
    Qt4
    Platforms
    Windows Android
    Thanks
    69
    Thanked 10 Times in 8 Posts

    Default Re: QGraphicsItem selection rectangle

    As for the first question, it might be helpful to set the itemIsSelectable/itemIsFocusable flags, although I know neither if it is set by default, nor exactly if it will do the trick. If not, style sheets might be an option. Just random thoughts.
    As for the latter, the funcionality to manually resize QGraphicsItems is afaik not built in, so you'll have to subclass it and build this behaviour by yourself.
    As I am a beginner, too, I might get proven wrong by the experts here, especially concerning the first question. I'm pretty sure about the second, though.

  3. #3
    Join Date
    Mar 2010
    Posts
    11
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsItem selection rectangle

    Quote Originally Posted by sedi View Post
    it might be helpful to set the itemIsSelectable/itemIsFocusable flags
    Forgot to write that, i already set this flag. Items got selection (isSelected() returning true) but the problem is selection rectangle didn't appear


    Edit:
    I kinda solved this but im not sure it is good way. In paint method i added something like "if(this->isSelected()) {/*code*/}" and drawing selectin rectangle by my own, its seems works fine, what you think? However, Im still wondering why that automatic selection rect didnt work.
    Last edited by ithinkso; 27th April 2012 at 12:02.

Similar Threads

  1. Replies: 0
    Last Post: 2nd November 2010, 19:54
  2. How to remove the dotted rectangle of selection
    By jiveaxe in forum Qt Programming
    Replies: 5
    Last Post: 18th April 2010, 23:00
  3. Drawing a selection rectangle
    By Caius Aérobus in forum Qt Programming
    Replies: 7
    Last Post: 4th April 2009, 16:47
  4. QTableView, no selection rectangle
    By alisami in forum Qt Programming
    Replies: 13
    Last Post: 25th December 2008, 20:50
  5. How to paint a selection rectangle on a pixmap?
    By SkripT in forum Qt Programming
    Replies: 6
    Last Post: 8th January 2006, 20:52

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
  •  
Qt is a trademark of The Qt Company.