Results 1 to 4 of 4

Thread: How to detect QT Mouse events outside a application window?

  1. #1
    Join Date
    Sep 2013
    Posts
    3
    Qt products
    Qt5
    Platforms
    MacOS X

    Question How to detect QT Mouse events outside a application window?

    Hello,
    I am trying to get the log when a mouse is moved outside a QT app window.
    I have a QTGraphicsScene which zooms on mouse wheel.

    Basically I am drawing a line from 1 point to other by left click using QPainter till the point on the scene I release on mouse down.
    The problem happens when I zoom the scene and start drawing the line. But when the mouse cursor goes outside the app window
    the line is drawn and no further detection of mouse happens even if I return back to the scene.

    So I tried this :
    void ClassName::mouseMoveEvent(QGraphicsSceneMouseEvent *event){

    Qt Code:
    1. if (event->type() == QEvent::FocusOut) {
    2. cout<<"----------///FocusOut -----------------------"<<endl;
    3. }
    4. }
    To copy to clipboard, switch view to plain text mode 


    I just need to know is their a way to detect mouse movements outside a QT app window.

    Thankx in advance!!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to detect QT Mouse events outside a application window?

    QWidget::leaveEvent(), QWidget::enterEvent()

    Cheers,
    _

  3. #3
    Join Date
    Sep 2013
    Posts
    3
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: How to detect QT Mouse events outside a application window?

    I am stuck badly in this...
    I cannot implement simultaneous mouse events in 2 separate class (as per above solution) as I don't which one will be fired first and how to then inform the second mouse event one about it.
    I have a QGraphicsSceneMouseEvent running for a QGraphicsScene inside QGraphicsView. So I want to determine when a mouse event (from QGraphicsSceneMouseEvent) runs outside a QApplication window.
    Isn't their any direct function call API for this determining whether the mouse move event goes outside app window?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to detect QT Mouse events outside a application window?

    Quote Originally Posted by Danie View Post
    Isn't their any direct function call API for this determining whether the mouse move event goes outside app window?
    Yes. QWidget::leaveEvent()

    Cheers,
    _

Similar Threads

  1. How to detect hover events when mouse button is pressed
    By yagabey in forum Qt Programming
    Replies: 12
    Last Post: 26th April 2016, 09:23
  2. How to get mouse click events outside the Qt window?
    By montylee in forum Qt Programming
    Replies: 11
    Last Post: 13th July 2015, 21:55
  3. Replies: 3
    Last Post: 12th August 2012, 13:49
  4. Replies: 2
    Last Post: 4th November 2010, 10:10
  5. Catching Mouse Events on Top-Level Window
    By andyp in forum Qt Programming
    Replies: 6
    Last Post: 8th September 2009, 10:26

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.