Results 1 to 2 of 2

Thread: Increasing the selection area for a qgraphicsPathitem

  1. #1
    Join Date
    Jul 2007
    Posts
    39
    Thanks
    10

    Default Increasing the selection area for a qgraphicsPathitem

    Hi all

    I am having a problem with my QGraphicView framework. I want to select an QGraphcsPathItem by clicking on an an area surrounding the item. This area is +5 pixels on all sides on the item's bounding rect. I did the following:

    QRectF boundingRect() const
    { return QGraphicsItem::boundingRect().adjusted(-5, -5, +5, +5); }

    bool contains(const QPointF &point) const
    { return boundingRect().contains(point); }
    The mouse click on the area surrounding the boundingRect is received by the item. I checked this by subclassing the mousePressEvent(). But the item is not getting selected this way. The item is a pathItem. So would it only get selected if clicked on the path?

    Thanks
    Arjun
    Last edited by arjunasd; 17th August 2007 at 22:38.

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Increasing the selection area for a qgraphicsPathitem

    I think you must reimplement QGraphicsItem::shape() and return a path containing the bounding rect.
    J-P Nurmi

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.