Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6721823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:22:29+00:00 2026-05-26T09:22:29+00:00

I need to catch when a User moves the mouse over the GUI, but

  • 0

I need to catch when a User moves the mouse over the GUI, but not when they’re holding down the mouse button (which would do something different).

I can’t find any conveniant method to do this,
except to periodically find the mouse position and check it to it’s previous position…
Which would suck.

The mouseMoveEvent is only called when the mouse is moved whilst the left mouse button is pressed,
unless ofcourse the widget has ‘mouse tracking’. Mouse tracking is not an option for me, because the GUI must behave differently when the mouse is moved and the left mouse button is pressed.

Are there any inbuilt methods to do this?
(or just any clever ideas?)

eg:
Is there a way to check if the left mouse button is being pressed at any time?
Or a ‘mouse hover’ event that can be applied to a QRect (coordinates)?

Muchas gracias.


Windows 7 (32)
python 2.7
PyQt4

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:22:29+00:00Added an answer on May 26, 2026 at 9:22 am

    The most straightforward way to do this is to install an event filter on qApp:

    from PyQt4 import QtGui, QtCore
    
    class Window(QtGui.QMainWindow):
        def __init__(self):
            QtGui.QMainWindow.__init__(self)
            widget = QtGui.QWidget(self)
            layout = QtGui.QVBoxLayout(widget)
            self.edit = QtGui.QLineEdit(self)
            self.list = QtGui.QListWidget(self)
            layout.addWidget(self.edit)
            layout.addWidget(self.list)
            self.setCentralWidget(widget)
    
        def eventFilter(self, source, event):
            if event.type() == QtCore.QEvent.MouseMove:
                if event.buttons() == QtCore.Qt.NoButton:
                    pos = event.pos()
                    self.edit.setText('x: %d, y: %d' % (pos.x(), pos.y()))
                else:
                    pass # do other stuff
            return QtGui.QMainWindow.eventFilter(self, source, event)
    
    if __name__ == '__main__':
    
        import sys
        app = QtGui.QApplication(sys.argv)
        win = Window()
        win.show()
        app.installEventFilter(win)
        sys.exit(app.exec_())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to catch that exception but I can't figure out which one it
VB 6.0 does not have any global handler.To catch runtime errors,we need to add
Since there is no need to try/catch or specify un-checked exceptions, how are they
I have a Datagridview, on which I need to validate the user input on
I need to catch an event when the user presses the back key and
i have a simple problme. I need to catch when a user enter an
In my application, I need to catch the event of user log out of
I'm developing an application in which I need to catch and respond to Authentication
I need to catch the HTML of a ASP.NET just before it is being
I need to catch segmentation fault in third party library cleanup operations. This happens

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.