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. How do I know if the mouse is moved out of the widget when I use multiple levels widgets?
Forum Updated to NodeBB v4.3 + New Features

How do I know if the mouse is moved out of the widget when I use multiple levels widgets?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 5 Posters 459 Views 3 Watching
  • 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.
  • J Offline
    J Offline
    John Van
    wrote on 25 Mar 2023, 03:09 last edited by John Van
    #1

    Hi,
    For example,the widget A contains subwidget B,B contains subwidget C.I want to achieve the aim of draging the edge of A to change size of A,so I overrided the MouseMoveEvent,MousePressEvent,MouseLeaveEvent of A,when cursor toward or away the edge I will change the shape of cursor .but when I move the cursor fastly ,the cursor enter B and not trigger any event of A.so the shape of cursor is incorrect,what shuold I do to avoid the situation?
    Thanks.

    S J 2 Replies Last reply 25 Mar 2023, 20:30
    0
    • J John Van
      25 Mar 2023, 03:09

      Hi,
      For example,the widget A contains subwidget B,B contains subwidget C.I want to achieve the aim of draging the edge of A to change size of A,so I overrided the MouseMoveEvent,MousePressEvent,MouseLeaveEvent of A,when cursor toward or away the edge I will change the shape of cursor .but when I move the cursor fastly ,the cursor enter B and not trigger any event of A.so the shape of cursor is incorrect,what shuold I do to avoid the situation?
      Thanks.

      S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 25 Mar 2023, 20:30 last edited by SGaist
      #2

      Hi and welcome to devnet,

      Are you trying to implement QSizeGrip ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply 27 Mar 2023, 06:09
      0
      • S SGaist
        25 Mar 2023, 20:30

        Hi and welcome to devnet,

        Are you trying to implement QSizeGrip ?

        J Offline
        J Offline
        John Van
        wrote on 27 Mar 2023, 06:09 last edited by
        #3

        @SGaist
        However, this widget does not meet all my expectations. I want to know how to avoid complex subwidgets intercepting certain events from the parent widget.
        Thank you.

        1 Reply Last reply
        0
        • J John Van
          25 Mar 2023, 03:09

          Hi,
          For example,the widget A contains subwidget B,B contains subwidget C.I want to achieve the aim of draging the edge of A to change size of A,so I overrided the MouseMoveEvent,MousePressEvent,MouseLeaveEvent of A,when cursor toward or away the edge I will change the shape of cursor .but when I move the cursor fastly ,the cursor enter B and not trigger any event of A.so the shape of cursor is incorrect,what shuold I do to avoid the situation?
          Thanks.

          J Offline
          J Offline
          JonB
          wrote on 27 Mar 2023, 07:44 last edited by
          #4

          @John-Van said in How do I know if the mouse is moved out of the widget when I use multiple levels widgets?:

          but when I move the cursor fastly ,the cursor enter B and not trigger any event of A

          Is it the MouseLeaveEvent which gets missed/does not occur? If that is the case but you still do get MouseMoveEvents then you could recognise those and figure out the enter/leaves for yourself. Not ideal but that may be all you have.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SimonSchroeder
            wrote on 27 Mar 2023, 09:11 last edited by
            #5

            Maybe you need to enable mouse tracking: https://doc.qt.io/qt-6/qwidget.html#mouseTracking-prop

            You can also try to shortly grab the mouse: https://doc.qt.io/qt-6/qwidget.html#grabMouse
            But don't forget to release it again for interaction in widget B when necessary.

            1 Reply Last reply
            0
            • J Offline
              J Offline
              John Van
              wrote on 28 Mar 2023, 05:48 last edited by
              #6

              I solved my problems.
              Thanks everyone for your reply.

              C 1 Reply Last reply 28 Mar 2023, 08:29
              0
              • J John Van
                28 Mar 2023, 05:48

                I solved my problems.
                Thanks everyone for your reply.

                C Offline
                C Offline
                CPPUIX
                wrote on 28 Mar 2023, 08:29 last edited by
                #7

                @John-Van could you share how you solved it? It might benefit a lot of people that read this post in the future

                J 1 Reply Last reply 28 Mar 2023, 11:43
                0
                • C CPPUIX
                  28 Mar 2023, 08:29

                  @John-Van could you share how you solved it? It might benefit a lot of people that read this post in the future

                  J Offline
                  J Offline
                  John Van
                  wrote on 28 Mar 2023, 11:43 last edited by
                  #8

                  @Abderrahmene_Rayene
                  In mouseMoveEvent,when the cursor close to edge of A I grabMouse to ensure the QMouseEvent will be received ,otherwise releaseMouse. https://doc.qt.io/qt-6/qwidget.html#grabMouse

                  1 Reply Last reply
                  1

                  1/8

                  25 Mar 2023, 03:09

                  • Login

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