[Qt-interest] setMouseTracking
Nikos Chantziaras
realnc at arcor.de
Thu Jan 6 17:05:23 CET 2011
On 01/06/2011 05:39 PM, "Alexander Carôt" wrote:
>> 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.
Isn't that what you want? Usually you don't want to receive mouse move
events for the application's menus and status bar. And if you don't have
a menu or a status bar, then the central widget is the same size of the
QMainWindow anyway, so "outside the widget's boundaries" doesn't even
exist; that would be the desktop...
More information about the Qt-interest-old
mailing list