Results 1 to 5 of 5

Thread: hoverover for boundingrect qgraphicsitem

  1. #1
    Join Date
    Mar 2009
    Location
    Nashville Tn.
    Posts
    53
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default hoverover for boundingrect qgraphicsitem

    is there a way to check if mouse is over (within) the boundingrect for a qgraphicsitem. (akin to hoverover)
    Last edited by rogerholmes; 11th January 2010 at 01:39.

  2. #2
    Join Date
    Nov 2007
    Posts
    31
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: hoverover for boundingrect qgraphicsitem

    Quote Originally Posted by rogerholmes View Post
    is there a way to check if mouse is over (within) the boundingrect for a qgraphicsitem. (akin to hoverover)
    If you write the custom item class, you can handle hoverEnterEvent()、hoverLeaveEvent()、hoverMoveEvent ().
    By default, items do not accept hover events. so it is necessary to call setAcceptHoverEvents(true).

    I'm sorry in poor English.
    kichi

  3. #3
    Join Date
    Mar 2009
    Location
    Nashville Tn.
    Posts
    53
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: hoverover for boundingrect qgraphicsitem

    Kichi,

    Thank You for you response.

    I am using that. I need a similar functionally for boundingrect, hover events only fire when the mouse is over the actual image, i want to have a method fire when mouse is over the boundingrect of the image.

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

    Default Re: hoverover for boundingrect qgraphicsitem

    Quote Originally Posted by rogerholmes View Post
    is there a way to check if mouse is over (within) the boundingrect for a qgraphicsitem. (akin to hoverover)
    It really depends on the context. The simplest way would be to use this:

    Qt Code:
    1. QPointF pos = ...
    2. bool inside = item->boundingRect().contains(pos);
    To copy to clipboard, switch view to plain text mode 
    If you can have the position of the cursor in item coordinates (i.e. in item events containing the cursor position).

    If you have the position of the cursor relative to the scene or the view then you can use the family of mapTo* or mapFrom* to get to local coordinates and use the code above.
    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.


  5. The following user says thank you to wysota for this useful post:

    rogerholmes (11th January 2010)

  6. #5
    Join Date
    Mar 2009
    Location
    Nashville Tn.
    Posts
    53
    Thanks
    14
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: hoverover for boundingrect qgraphicsitem

    Thank You Wysota,

    I will try that.

Similar Threads

  1. Having problem with QGraphicsItem
    By Kingofhearts_sri in forum Qt Programming
    Replies: 4
    Last Post: 23rd January 2009, 20:10
  2. Casting QGraphicsItem child from QGraphicsItem
    By patrik08 in forum Qt Programming
    Replies: 3
    Last Post: 29th August 2008, 16:37
  3. Replies: 2
    Last Post: 28th June 2008, 17:31
  4. Is it possible to use QPainter with QGraphicsItem?
    By william.dias in forum Qt Programming
    Replies: 4
    Last Post: 2nd February 2008, 11:19
  5. label as a QGraphicsItem
    By magland in forum Qt Programming
    Replies: 1
    Last Post: 29th December 2007, 18:24

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.