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

Shortcuts Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 896 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.
  • M Offline
    M Offline
    Martinuccia_96
    wrote on last edited by
    #1

    I want to disable all the possible shortcuts in QTextEdit except the Ctrl+V and Ctrl+C ones.
    Someone can help me. I can't do this.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What other shortcuts are you referring to ?
      What did you try ?

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

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Martinuccia_96
        wrote on last edited by
        #3

        I mean the Undo-Redo shortcuts for example.
        I've tried to filter the event and ignore it. But it doesn't work

        J.HilkJ 1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The widget is equipped with an undo stack. Out of curiosity, why do you want to disable it ?

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

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Martinuccia_96
            wrote on last edited by Martinuccia_96
            #5

            I need to disable them for a project in which I need to process only Ctrl+V, Ctrl+C,Ctrl+X.
            Whenever I use a combination of Ctrl+another key, I want that nothing happens in my QTextEdit.
            I've tried to install an eventFilter into my class, and I've used the following code:

            ui->textEdit->installEventFilter(this);
            

            I've used the following code to ignore the event:

            bool notepad::isAKeyToIgnore(QKeyEvent* event){
                return  event->modifiers() & Qt::ControlModifier;
            }
            

            but however the events that I've inserted into the if statement are processed .

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Did you also handle QShortCutEvent ?

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

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Martinuccia_96
                wrote on last edited by
                #7

                what do you mean?

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  Bonnie
                  wrote on last edited by Bonnie
                  #8

                  @SGaist means besides QEvent::KeyPress, you can also try to handle QEvent::Shortcut in eventFilter.

                  1 Reply Last reply
                  1
                  • M Martinuccia_96

                    I mean the Undo-Redo shortcuts for example.
                    I've tried to filter the event and ignore it. But it doesn't work

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #9

                    @Martinuccia_96 if it's only the undo/redo shortcuts, you can simply disable the redo stack
                    https://doc.qt.io/qt-5/qtextedit.html#undoRedoEnabled-prop
                    and they should no longer have a functionality


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    SGaistS 1 Reply Last reply
                    1
                    • J.HilkJ J.Hilk

                      @Martinuccia_96 if it's only the undo/redo shortcuts, you can simply disable the redo stack
                      https://doc.qt.io/qt-5/qtextedit.html#undoRedoEnabled-prop
                      and they should no longer have a functionality

                      SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @J-Hilk said in Shortcuts Qt:

                      @Martinuccia_96 if it's only the undo/redo shortcuts, you can simply disable the redo stack
                      https://doc.qt.io/qt-5/qtextedit.html#undoRedoEnabled-prop
                      and they should no longer have a functionality

                      Funny, I was looking for that property the other day and did not find it 😅

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

                      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