Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Where can I see the implementation of void QWidget::leaveEvent(QEvent * event) ?
redstoneleo9 last edited by redstoneleo9
I tested on Win7 that when mouse cursor is hovering on the title bar of a window,then the event is triggered , while I don't want it to happen in this case, so to reimplement the method seems the only way to solve the problem, before doing this, I want to get some inspiration by seeing the implementation of void QWidget::leaveEvent(QEvent * event) , so
- where can I see it ? Please give a link to the implementation of this function ,thanks !
- any solution on stopping the event from happening when mouse cursor is hovering on the title bar of a window would be appreciated !
Joel Bodenmann last edited by Joel Bodenmann
I am not a Qt guru at all but I am pretty sure that you will not succeed at preventing that behavior.
QWidget::leaveEvent()is triggered as soon as the mouse cursor/pointer leaves the widget area.
The problem is that the title bar of the window is not part of the widget. It is called 'Window Decoration' and it is up to the window manager how this is handled. The default window manager of Windows renders a title bar, but there are window managers which don't render those at all.
Because this is outside of the QWidget stuff, you will never know whether you are inside or outside the window (decoration) borders of your window manager from inside of the Qt application.
But I might be horribly wrong here. Maybe there is some workaround for this.
To Answer your other question, you can find the default implementation of
redstoneleo9 last edited by
@Joel-Bodenmann ok,thanks, but can you share the method that you find the default implementation of QWidget::leaveEvent() ?
Joel Bodenmann last edited by
I googled for Qt source repository. Somewhere in a (wiki?) on the official Qt website there is a link to all their repositories: http://code.qt.io/cgit/qt/
From there it is either just knowing that the QWidget stuff is in the qtbase project or a simple Ctrl+F for "widget" will also do. Click on that repository and go to the Tree tab. Then src -> widgets and from there it was just a couple of more Ctrl+F to figure out that qwidget.cpp is part of the kernel directory.
I never browser the Qt sources myself before. It really just was 30 seconds of Ctrl+F magic :)