Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved how to capture a mouse leave event only on a specific QWidget ( a QlineEdit ) ?

    General and Desktop
    qmouseevent qlineedit
    4
    6
    867
    Loading More Posts
    • 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.
    • Lemat
      Lemat last edited by aha_1980

      i want to capture a mouse leave event only on a specific QWidget ( a QlineEdit ). one way to do is to inherit from that class and over ride the virtual function , but i cant do that since i'm using QtDesigner

      Time to elevate.

      JonB 1 Reply Last reply Reply Quote 0
      • JonB
        JonB @Lemat last edited by

        @Lemat
        I don't know about/use Qt Designer. Can you use eventFilter() (https://doc.qt.io/qt-5/qobject.html#eventFilter) instead?

        1 Reply Last reply Reply Quote 7
        • JonB
          JonB @Lemat last edited by

          @Lemat
          I don't know about/use Qt Designer. Can you use eventFilter() (https://doc.qt.io/qt-5/qobject.html#eventFilter) instead?

          1 Reply Last reply Reply Quote 7
          • A
            Alain38 0 last edited by

            Hi,
            The procedure is exactly what you expected. Subclass QLineEdit. Then, on QtDesigner, place a standard QLineEdit. Right-click on it. You will see an item "Promote to". Select it. A window will be displayed to choose the class. As none is present, you will have to give it the name of your class, and the location of the .h file (or click on "global" if the project has the access path).

            Lemat 1 Reply Last reply Reply Quote 5
            • mrjj
              mrjj Lifetime Qt Champion last edited by

              Hi
              As @Alain38-0 talks about. You can still use your own subclass with Designer.
              That feature is called Promotion
              https://doc.qt.io/qt-5/designer-using-custom-widgets.html

              1 Reply Last reply Reply Quote 1
              • Lemat
                Lemat last edited by Lemat

                Okay, thanks for all. i used

                eventFilter();
                

                and it work!!!.

                Time to elevate.

                1 Reply Last reply Reply Quote 1
                • Lemat
                  Lemat @Alain38 0 last edited by

                  @Alain38-0 okay, i will use it for another project. thanks.

                  Time to elevate.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post