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. Intercept key on QLineEdit
QtWS25 Last Chance

Intercept key on QLineEdit

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.2k 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.
  • F Offline
    F Offline
    fermatqt
    wrote on last edited by
    #1

    hi!

    I need to intercept the F8 key when I'm on a QLineEdit.
    it's possible?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Use event filters for line edit.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      F 1 Reply Last reply
      4
      • dheerendraD dheerendra

        Use event filters for line edit.

        F Offline
        F Offline
        fermatqt
        wrote on last edited by
        #3

        @dheerendra

        ok, i did something like this, and seems to work:

        bool ForzaTestataContab::eventFilter(QObject *obj, QEvent *event) {
            QKeyEvent *key = static_cast<QKeyEvent *>(event);
            if (obj == editCondPag && event->type() == QEvent::KeyPress && key->key() == 16777271) {
                HelpWindow *help = new HelpWindow("get_cond_pag_all.txt");
                help->show();
            } else if (obj == editVett1 && event->type() == QEvent::KeyPress && key->key() == 16777271) {
                HelpWindow *help = new HelpWindow("get_vettori.txt");
                help->show();
            }
            return QObject::eventFilter(obj, event);
        }
        

        tks!!

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          My inputs. Don't compare key with big number. Check qt::key_f8. It is good practice.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          F 1 Reply Last reply
          6
          • dheerendraD dheerendra

            My inputs. Don't compare key with big number. Check qt::key_f8. It is good practice.

            F Offline
            F Offline
            fermatqt
            wrote on last edited by
            #5

            @dheerendra said in Intercept key on QLineEdit:

            My inputs. Don't compare key with big number. Check qt::key_f8. It is good practice.

            ok, thanks a lot!!

            1 Reply Last reply
            1

            • Login

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