[PyKDE] setMouseTracking

Hans-Peter Jansen hpj at urpla.net
Thu Apr 10 20:30:01 BST 2003


On Wednesday 09 April 2003 22:08, Frederick Polgardy Jr wrote:
> Huh, it's true.  This code only shows me mouse tracking when the
> mouse is down:

Hi Fred et al.,

I slightly modified your code sniplet to get it working.

Kudos goes to Jim for the idea!

Hopefully somebody finds it useful.

Funny is, viewport starts with (-1,-1) here 8)

hp

import sys

from qt import *
from qtcanvas import *

class MyCanvasView(QCanvasView):
   def __init__(self, *args):
      QCanvasView.__init__(self, QCanvas(), *args)
      self.resize(200, 200)
      self.viewport().setMouseTracking(True)

   def contentsMouseMoveEvent(self, e):
      self.parentWidget().statusBar().message("(%d, %d)" % (e.x(), e.y()))

app = QApplication(sys.argv)
w = QMainWindow()
app.setMainWidget(w)

c = MyCanvasView(w)
w.setCentralWidget(c)
w.statusBar()

w.show()
app.exec_loop()




More information about the PyQt mailing list