Results 1 to 4 of 4

Thread: QGraphicsItem mouse out of focus

  1. #1
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default QGraphicsItem mouse out of focus

    Hey guys,

    I want to emulate a "real button click" on a QGraphicsItem:
    The click is triggered when mouse release + cursor inside.

    Anyone could fill my blank here:

    Qt Code:
    1. void qwListGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
    2. {
    3. Q_D(qwListGraphicsItem);
    4.  
    5. if (/* cursor is not over the QGraphicsItem */ == true) return;
    6.  
    7. // Do something...
    8. }
    To copy to clipboard, switch view to plain text mode 

    Thanks.

  2. #2
    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 mouse out of focus

    What is a "real button click"? You will only get the release event if the cursor hits the shape() of the item. Is that "inside" enough?
    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.


  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsItem mouse out of focus

    If you want your item to be shown as pressed,,, try to set its pos little by some offset while it is pressed.
    Also you can change color of the item to give more realistic effect. Hope am getting u right

  4. #4
    Join Date
    Jan 2007
    Location
    Paris
    Posts
    459
    Thanks
    98
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5

    Default Re: QGraphicsItem mouse out of focus

    Solved : QGraphicsItem::isUnderMouse()
    Qt Code:
    1. void qwListGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent * event)
    2. {
    3. Q_D(qwListGraphicsItem);
    4.  
    5. if (isUnderMouse() == false) return;
    6.  
    7. // Do something...
    8. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QGraphicsItem no mouse events called
    By munna in forum Qt Programming
    Replies: 11
    Last Post: 9th December 2009, 14:43
  2. how to prevent qgraphicsitem repaint while mouse move on it
    By christina123y in forum Qt Programming
    Replies: 22
    Last Post: 17th April 2009, 10:17
  3. QGraphicsItem and focus for key input
    By fossill in forum Qt Programming
    Replies: 2
    Last Post: 9th February 2007, 19:13
  4. Mouse events without focus
    By latte in forum Qt Programming
    Replies: 1
    Last Post: 6th February 2007, 12:36
  5. Replies: 2
    Last Post: 24th July 2006, 18:36

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.