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. Press "Enter"
Qt 6.11 is out! See what's new in the release blog

Press "Enter"

Scheduled Pinned Locked Moved General and Desktop
10 Posts 5 Posters 7.9k Views 1 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.
  • R Offline
    R Offline
    Ruzik
    wrote on last edited by
    #1

    Hellow, i have some problem:
    I have a code:
    @ if (e->key()==Qt::Key_Enter)
    {
    qDebug() << "1";
    emit makeIndent();
    }@
    It is doesnt work, but this code worke wright
    @ if (e->key()==Qt::Key_E)
    {
    qDebug() << "1";
    emit makeIndent();
    }@
    I need that signal will called when user press key "Enter" to move to the next line

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      I guess the eventfilter for your widget or dialog intercepts the event to use it for something else. You should either make sure that you use a widget that will receive that event, or you should use an eventfilter yourself to get it before it is intercepted.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Ruzik
        wrote on last edited by
        #3

        First, I think so too, but this code is first in the keyPressEvent:
        @void qssTextEdit::keyPressEvent(QKeyEvent *e)
        {
        if (e->key()==Qt::Key_Enter)
        {
        qDebug() << "1";
        emit makeIndent();
        }
        //Next code
        @
        And there are no any key filters in program. Code worke wright if instead "Enter" use Escape or Tab in example

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          eventfilter for your widget or dialog

          are you using a QDialog? Or which type of widget do you use?
          Enter is often caught for special actions, in dialog, e.g. to activate the default button.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Ruzik
            wrote on last edited by
            #5

            I use QPlainTextEdit

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Scylla
              wrote on last edited by
              #6

              Do you use the QPlainTextEdit within a QDialog? The QDialog catch the Enter key. So do you have to install a eventFilter.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Ruzik
                wrote on last edited by
                #7

                I use QPlainTextEdit in the QMainWindow

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tobias.hunger
                  wrote on last edited by
                  #8

                  Do you want Key_Enter or Key_Return?

                  Key_Enter usually is the small enter key on the keypad.

                  1 Reply Last reply
                  0
                  • R Offline
                    R Offline
                    Ruzik
                    wrote on last edited by
                    #9

                    In fact i use modified class from Custom Completer Example

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      Ruzik
                      wrote on last edited by
                      #10

                      Tobias Hunger, you are right
                      Many thanks for all!!

                      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