Results 1 to 13 of 13

Thread: How to detect hover events when mouse button is pressed

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: How to detect hover events when mouse button is pressed

    If you want to perform mouse TRACKING, there is a setting for that in the Widget class
    I am dealing with QGraphicsItem. Since it is not a subclass of QWidget there is no such setting.

    Perhaps I am expressing it in the wrong way. More clearly step by step:
    1) Left mouse button is pressed anywhere on the scene and hold pressed
    2) Now the cursor goes through my QGraphicsItem object
    3) Result: None of mouse events are detected

    As Wysota said the scene is the mouse grabber; so that is an expected behaviour. But i am still curious if there is an alternative method to achieve my goal

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

    Default Re: How to detect hover events when mouse button is pressed

    I am dealing with QGraphicsItem. Since it is not a subclass of QWidget there is no such setting.
    But you don't want to intercept events on the GraphicsItem; you want to intercept them within the GraphicsView. Which is a ScrollArea.

    In any case, more primitive tracking is the only way to do what you're asking. Once things have progressed to the level of hovering, no meaningful such events are going to occur over your GraphicsItem. You have to take responsibility for implementing such handling at a lower level, as noted above.

  3. The following user says thank you to SixDegrees for this useful post:

    yagabey (21st May 2011)

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

    Default Re: How to detect hover events when mouse button is pressed

    Quote Originally Posted by yagabey View Post
    I am dealing with QGraphicsItem. Since it is not a subclass of QWidget there is no such setting.

    Perhaps I am expressing it in the wrong way. More clearly step by step:
    1) Left mouse button is pressed anywhere on the scene and hold pressed
    2) Now the cursor goes through my QGraphicsItem object
    3) Result: None of mouse events are detected

    As Wysota said the scene is the mouse grabber; so that is an expected behaviour. But i am still curious if there is an alternative method to achieve my goal
    Could you say what you need this functionality for? Maybe there are better ways to achieve it.
    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. #4
    Join Date
    Jul 2013
    Posts
    15
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to detect hover events when mouse button is pressed

    I'm sorry to up the topic, but I've got the exact same problem.

    I want to create a Map Editor. I use QGraphics Scene and QGraphics View to draw the map, and I use QGraphicsItem for every tiles (32x32 pixels). I have two areas : One is the tileset where I can select the tile I want to use, and the other represents the map where I can use my selected tile and put it where I want on the map.

    My problem is : If I click a tile and then I move my mouse to another tile, it doesn't draw the selected tiles on both of them, but only on the one I clicked first.
    Also: I use the hoverEvent to draw cursor on the tiles. When I move my mouse on a tile, it shows that I want to select THIS tile. But if I click it and then I move, the cursor doesn't follow the mouse anymore.

    I don't know if my problem is clear but I would apreciate very much if you could help me !
    (Sorry for my bad english).

  6. #5
    Join Date
    Apr 2016
    Posts
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Windows Android

    Default Re: How to detect hover events when mouse button is pressed

    Quote Originally Posted by wysota View Post
    Could you say what you need this functionality for? Maybe there are better ways to achieve it.
    I still got is problem currently, and how you finally deal with it ?

    Quote Originally Posted by Grade View Post
    I'm sorry to up the topic, but I've got the exact same problem.

    I want to create a Map Editor. I use QGraphics Scene and QGraphics View to draw the map, and I use QGraphicsItem for every tiles (32x32 pixels). I have two areas : One is the tileset where I can select the tile I want to use, and the other represents the map where I can use my selected tile and put it where I want on the map.

    My problem is : If I click a tile and then I move my mouse to another tile, it doesn't draw the selected tiles on both of them, but only on the one I clicked first.
    Also: I use the hoverEvent to draw cursor on the tiles. When I move my mouse on a tile, it shows that I want to select THIS tile. But if I click it and then I move, the cursor doesn't follow the mouse anymore.

    I don't know if my problem is clear but I would apreciate very much if you could help me !
    (Sorry for my bad english).
    I still got is problem currently, and how you finally deal with it ?
    thanks.

Similar Threads

  1. Replies: 6
    Last Post: 4th October 2010, 03:19
  2. Replies: 0
    Last Post: 26th June 2010, 00:40
  3. Replies: 2
    Last Post: 13th May 2009, 19:01
  4. problem about mouse button events
    By vql in forum Qt Programming
    Replies: 1
    Last Post: 29th April 2008, 10:14
  5. QPushButton:: Handle right mouse button events. Easyway?
    By Harvey West in forum Qt Programming
    Replies: 6
    Last Post: 28th February 2007, 16:56

Tags for this Thread

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.