Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Where can I see the implementation of void QWidget::​leaveEvent(QEvent * event) ?
QtWS25 Last Chance

Where can I see the implementation of void QWidget::​leaveEvent(QEvent * event) ?

Scheduled Pinned Locked Moved General and Desktop
qwidgetsource code
4 Posts 2 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    redstoneleo9
    wrote on last edited by redstoneleo9
    #1

    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

    1. where can I see it ? Please give a link to the implementation of this function ,thanks !
    2. any solution on stopping the event from happening when mouse cursor is hovering on the title bar of a window would be appreciated !
    Joel BodenmannJ 1 Reply Last reply
    0
    • R 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

      1. where can I see it ? Please give a link to the implementation of this function ,thanks !
      2. any solution on stopping the event from happening when mouse cursor is hovering on the title bar of a window would be appreciated !
      Joel BodenmannJ Offline
      Joel BodenmannJ Offline
      Joel Bodenmann
      wrote on last edited by Joel Bodenmann
      #2

      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 QWidget::leaveEvent() here: http://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/kernel/qwidget.cpp#n9487

      Industrial process automation software: https://simulton.com
      Embedded Graphics & GUI library: https://ugfx.io

      R 1 Reply Last reply
      1
      • Joel BodenmannJ 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 QWidget::leaveEvent() here: http://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/kernel/qwidget.cpp#n9487

        R Offline
        R Offline
        redstoneleo9
        wrote on last edited by
        #3

        @Joel-Bodenmann ok,thanks, but can you share the method that you find the default implementation of QWidget::leaveEvent() ?

        Joel BodenmannJ 1 Reply Last reply
        0
        • R redstoneleo9

          @Joel-Bodenmann ok,thanks, but can you share the method that you find the default implementation of QWidget::leaveEvent() ?

          Joel BodenmannJ Offline
          Joel BodenmannJ Offline
          Joel Bodenmann
          wrote on last edited by
          #4

          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 :)

          Industrial process automation software: https://simulton.com
          Embedded Graphics & GUI library: https://ugfx.io

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved