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. QKeySequence. How to re-define standard keyboard shotcut?
Forum Updated to NodeBB v4.3 + New Features

QKeySequence. How to re-define standard keyboard shotcut?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 4.3k 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.
  • B Offline
    B Offline
    blex
    wrote on last edited by
    #1

    QKeySequence defines many QKeySequence::StandardKey {standard
    keyboard shortcuts} to reduce the amount of effort required when
    setting up actions in a typical application.

    Some key combinations (Ctrl+W in my case) are hard-coded in QKeySequence.cpp

    The list of hard-coded key sequences are provided in the QKeySequence class documentation.

    If the QAction is created with the same shot-cut then slot is not called and the following message is printed:

    @QAction::eventFilter: Ambiguous shortcut overload: Ctrl+W@

    How can I re-define Ctrl+W key combination?


    Oleksiy Balabay

    1 Reply Last reply
    0
    • R Offline
      R Offline
      RazrFalcon
      wrote on last edited by
      #2

      Can you show code where you create yours shortcut?

      1 Reply Last reply
      0
      • B Offline
        B Offline
        blex
        wrote on last edited by
        #3

        I modified the examples\mainwindows\mdi

        @MdiChild::MdiChild()
        {
        setAttribute(Qt::WA_DeleteOnClose);
        isUntitled = true;
        QKeySequence ks("Ctrl+W");
        QAction* a = new QAction(this);
        a->setShortcut(ks);
        connect(a, SIGNAL(triggered()), this, SLOT(ctrlWPressed()));
        addAction(a);
        }

        void MdiChild::ctrlWPressed() {
        qDebug("CtlW pressed");
        }
        @

        And the correspondent slot declaration in the header file.


        Oleksiy Balabay

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

          The QMdiArea defines Ctrl+W as shortcut for closing a MDI subwindow.

          Why do you want to change the standard behavior? You most probably are going to annoy your users...

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • B Offline
            B Offline
            blex
            wrote on last edited by
            #5

            [quote author="Volker" date="1322222474"]The QMdiArea defines Ctrl+W as shortcut for closing a MDI subwindow.

            Why do you want to change the standard behavior? You most probably are going to annoy your users...[/quote]

            I want to change the standard behavior because it is the end-user requirement :)


            Oleksiy Balabay

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              The shortcut is set in QMdiSubWindowPrivate::createSystemMenu() during the construction of a QMdiSubWindow, I doubt that you can remove it without having to patch Qt libs.

              http://www.catb.org/~esr/faqs/smart-questions.html

              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