[Qt-interest] setMouseTracking
Jan
janusius at gmx.net
Thu Jan 6 18:45:38 CET 2011
Just an idea:
Maybe it is possible to install an eventfilter on the QDesktopWidget
QDesktopWidget * QApplication::desktop ()
Through an eventfilter you may get mouse events. No idea if you can
enable mousetracking for the desktop widget (but it is a widget subclass
- so why not).
Jan
Am 06.01.2011 16:39, schrieb "Alexander Carôt":
>> Does your main window derive from QMainWindow or just QWidget? If not,
>> what happens if you create a QMainWindow and set your current "main
>> window" widget as the QMainWindow's centralWidget()? I believe this
>> should work (and is the common way of implementing a top level
>> application window.)
>
> In fact my window derives from QWidget. Changing it to QMainWindow makes it receive mouseMoveEvents without clicking as desired - thank you !
>
> However, it does not work if the mouse resides outside the window. So I changed my class back to QWidget and followed your suggestion of creating an extra QMainWindow and set my widget as the central widget via setCentralWidget(); In that context I also overwrote the mouse event handler of the QMainWindow with mouse pos messages. Unfortunately this didn't solve the problem either: Only the central widget's handler fired only when placing the mouse on it and not outside the widget's boundaries.
>
> Did I correctly follow you suggestion or am I possibly mistaken ?
>
> Thanks and best
>
> Alex
>
More information about the Qt-interest-old
mailing list