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 set hotkey's that work in Linux?
Forum Updated to NodeBB v4.3 + New Features

How to set hotkey's that work in Linux?

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 481 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by SPlatten
    #1

    I am using QMenu and QAction, I can set and see the visual aid of the hotkey by using underscore, e.g. &Menu works and shows an underscore on the M, but using the Alt+M combination does not trigger the action in Linux.

    Using the mouse and clicking on the menu works, this is using Qt 4.8.4

    Kind Regards,
    Sy

    JonBJ 1 Reply Last reply
    0
    • SPlattenS Offline
      SPlattenS Offline
      SPlatten
      wrote on last edited by SPlatten
      #3

      @JonB , thank you, I've done this with:

      int intHotKeyIdx(strText.indexOf(clsMainWnd::mscchHotKeyIndicator));
      if ( intHotKeyIdx >= 0 ) {
          const QString cstrHotKey(strText.mid(intHotKeyIdx + 1, 1));
          const QKeySequence cobjKeySeq(cstrHotKey);
          pobjAction->setShortcut(cobjKeySeq);
      }
      

      Where clsMainWnd::mscchHotKeyIndicator is set to &.

      Kind Regards,
      Sy

      JonBJ 1 Reply Last reply
      0
      • SPlattenS SPlatten

        I am using QMenu and QAction, I can set and see the visual aid of the hotkey by using underscore, e.g. &Menu works and shows an underscore on the M, but using the Alt+M combination does not trigger the action in Linux.

        Using the mouse and clicking on the menu works, this is using Qt 4.8.4

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #2

        @SPlatten
        I don't know about Qt4.

        Under Qt5 (Ubuntu) I am using &s on top-level menu items like:

            QMenu *fileMenu = menuBar()->addMenu("&File");
        

        and that works --- Alt+F triggers it.

        I do not find that &s on the menu items that drop down from this respond to Alt, e.g. when I follow the above line with

        fileMenu->addAction("&Clear", this, &MainWindow::actionClear);
        

        the item does show with the C underscored but Alt+C does not trigger it.

        However, FWIW, for another menu I have:

        QMenu *solveMenu = menuBar()->addMenu("&Solve");
        solveMenu->addAction("St&ep", this, &MainWindow::actionSolveStep, QKeySequence(Qt::CTRL + Qt::Key_E));
        

        that item shows as Step Ctrl+E and I do find that clicking Ctrl+E triggers it.

        That's what I know!

        1 Reply Last reply
        0
        • SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by SPlatten
          #3

          @JonB , thank you, I've done this with:

          int intHotKeyIdx(strText.indexOf(clsMainWnd::mscchHotKeyIndicator));
          if ( intHotKeyIdx >= 0 ) {
              const QString cstrHotKey(strText.mid(intHotKeyIdx + 1, 1));
              const QKeySequence cobjKeySeq(cstrHotKey);
              pobjAction->setShortcut(cobjKeySeq);
          }
          

          Where clsMainWnd::mscchHotKeyIndicator is set to &.

          Kind Regards,
          Sy

          JonBJ 1 Reply Last reply
          0
          • SPlattenS SPlatten

            @JonB , thank you, I've done this with:

            int intHotKeyIdx(strText.indexOf(clsMainWnd::mscchHotKeyIndicator));
            if ( intHotKeyIdx >= 0 ) {
                const QString cstrHotKey(strText.mid(intHotKeyIdx + 1, 1));
                const QKeySequence cobjKeySeq(cstrHotKey);
                pobjAction->setShortcut(cobjKeySeq);
            }
            

            Where clsMainWnd::mscchHotKeyIndicator is set to &.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #4

            @SPlatten
            To close this thread then. You are a good/native English speaker, are you not? Would you therefore care to correct your topic title which includes

            set hotkey's [sic.] that work

            to be grammatically correct and not offend those of us who think that punctuation rules are there to be obeyed correctly? ;-)

            SPlattenS 1 Reply Last reply
            0
            • JonBJ JonB

              @SPlatten
              To close this thread then. You are a good/native English speaker, are you not? Would you therefore care to correct your topic title which includes

              set hotkey's [sic.] that work

              to be grammatically correct and not offend those of us who think that punctuation rules are there to be obeyed correctly? ;-)

              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #5

              @JonB , being just a young 52 year old British born and English speaking person, I cannot see anything wrong grammatically with what I've chosen for the subject, it is correct and accurately describes the problem.

              In Windows setting the text with an & in the text before the hot key is enough to get the hot get working, in Linux it isn't so the subject is perfectly correct.

              Kind Regards,
              Sy

              JonBJ 1 Reply Last reply
              0
              • SPlattenS SPlatten

                @JonB , being just a young 52 year old British born and English speaking person, I cannot see anything wrong grammatically with what I've chosen for the subject, it is correct and accurately describes the problem.

                In Windows setting the text with an & in the text before the hot key is enough to get the hot get working, in Linux it isn't so the subject is perfectly correct.

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote on last edited by
                #6

                @SPlatten said in How to set hotkey's that work in Linux?:

                I cannot see anything wrong grammatically with what I've chosen for the subject, it is correct and accurately describes the problem.

                OMG, really?!

                Grammar has nothing to do with "accurately describes the problem".

                Do you really think your hotkey's is correct?? You think that is how to write the plural of the word hotkey?! :)

                J.HilkJ 1 Reply Last reply
                0
                • JonBJ JonB

                  @SPlatten said in How to set hotkey's that work in Linux?:

                  I cannot see anything wrong grammatically with what I've chosen for the subject, it is correct and accurately describes the problem.

                  OMG, really?!

                  Grammar has nothing to do with "accurately describes the problem".

                  Do you really think your hotkey's is correct?? You think that is how to write the plural of the word hotkey?! :)

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

                  @JonB as a non native speaker, I was looking long and hard for a way to interpret that work in Linux as possessive for hotkey....

                  But I can't seem to do it :D


                  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.

                  JonBJ 1 Reply Last reply
                  0
                  • J.HilkJ J.Hilk

                    @JonB as a non native speaker, I was looking long and hard for a way to interpret that work in Linux as possessive for hotkey....

                    But I can't seem to do it :D

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #8

                    @J-Hilk
                    Not sure what you mean. But if I really need to spell it out it should be

                    How to set hotkeys that work in Linux?
                    

                    hotkeys is the plural of hotkey. hotkey's is a possessive, referring to something which "belongs to" one hoykey, like the hotkey's action. And hotkeys' is also a possessive, referring to something belonging to multiple hotkeys, like all the hotkeys' actions.

                    If you don't like the that,

                    How to set hotkeys which work in Linux?
                    

                    would be equally acceptable, possibly marginally preferable.

                    Here endeth the lesson. I do not wish to carp over spelling/grammar in English, but I would expect my colleague @SPlatten to be aware of this. The world is going to the dogs! No offence to anyone intended :)

                    P.S.
                    Go read Eats, Shoots & Leaves if you want to understand why punctuation rules can be so important in English. [No pandas were harmed in the writing of that book!]

                    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