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 to capture a mouse leave event only on a specific QWidget ( a QlineEdit ) ?

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

Scheduled Pinned Locked Moved Solved General and Desktop
qmouseeventqlineedit
6 Posts 4 Posters 1.5k 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.
  • L Offline
    L Offline
    Lemat
    wrote on 26 Dec 2019, 23:18 last edited by aha_1980
    #1

    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.

    J 1 Reply Last reply 26 Dec 2019, 23:51
    0
    • L Lemat
      26 Dec 2019, 23:18

      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

      J Offline
      J Offline
      JonB
      wrote on 26 Dec 2019, 23:51 last edited by
      #2

      @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
      7
      • A Offline
        A Offline
        Alain38 0
        wrote on 27 Dec 2019, 10:59 last edited by
        #3

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

        L 1 Reply Last reply 29 Dec 2019, 07:52
        5
        • M Offline
          M Offline
          mrjj
          Lifetime Qt Champion
          wrote on 27 Dec 2019, 11:35 last edited by
          #4

          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
          1
          • L Offline
            L Offline
            Lemat
            wrote on 29 Dec 2019, 07:50 last edited by Lemat
            #5

            Okay, thanks for all. i used

            eventFilter();
            

            and it work!!!.

            Time to elevate.

            1 Reply Last reply
            1
            • A Alain38 0
              27 Dec 2019, 10:59

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

              L Offline
              L Offline
              Lemat
              wrote on 29 Dec 2019, 07:52 last edited by
              #6

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

              Time to elevate.

              1 Reply Last reply
              0

              6/6

              29 Dec 2019, 07:52

              • Login

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