Using PyQt4.QtGui.QMouseEvent in a QWidget
<p>I am using a PyQt4.QMainWindow as my application interface, and I want to get the x and y coordinates of the mouse inside of a QWidget and set them continuously in 2 textBrowsers in the MainWindow.</p>

<p>The documentation for QWidget is <a href="http://pyqt.sourceforge.net/Docs/PyQt4/qwidget.html#mouseGrabber" rel="nofollow noreferrer">here</a>.</p>

<p>and the documentation for QMouseEvent is <a href="http://pyqt.sourceforge.net/Docs/PyQt4/qmouseevent.html" rel="nofollow noreferrer">here</a>.</p>

<p>Here is the code</p>

<pre><code>from PyQt4 import QtGui
from PyQt4.QtGui import QApplication
import sys

class Ui_MainWindow(object):
   def setupUI(self, MainWindow):
      self.textBrowser_1 = QtGui.QTextBrowser(self.tab)
      self.textBrowser_2 = QtGui.QTextBrowser(self.tab)
      self.widget_1 = QtGui.QWidget(self.tab)
      self.widget_1.setMouseTracking(True)

class MyMainScreen(QMainWindow):
def __init__(self, parent=None):
    QtGui.QMainWindow.__init__(self, parent)
    self.ui = Ui_MainWindow()   # This is from a python export from QtDesigner
    #   There is a QWidget inside that is self.ui.widget_1
    #   and 2 textBrowsers, textBrowser_1 and textBrowser_2
    #   I want to populate these 2 textBrowsers with the current x,y 
    #   coordinates.

if __name__ == "__main__":
    app = QApplication(sys.argv)
    mainscreen = MyMainScreen()           
    mainscreen.show()
    app.exec_()
</code></pre>