Forum
Sign Up

Display shortcut key from QAction in Ribbon

8 years 1 month ago #1 by Ludek
Hello there,

I'm wondering if it is possible to display shortcut from QAction in Ribbon control tooltip?


Attachments:

Please Log in or Create an account to join the conversation.

More
8 years 1 month ago #2 by Ludek
After short code debugging I think there is no such function, so I wrote it myself.

To enable this feature, add following lines to QtnRibbonStyle file line 3848
QAction * defAction = button->defaultAction();
if ( defAction )
{
  QKeySequence keyShortcut = defAction->shortcut();
  QString strShortcutString = keyShortcut.toString();
  strTitleText += " (" + strShortcutString + ")";
}

Here is a larger piece of code to see the whole context:

pastebin.com/mRc7VfNh

Please Log in or Create an account to join the conversation.

More
8 years 1 month ago #3 by Ludek
Update to display all available shortcuts and display shortcuts in Tip text (instad of title) if title is empty:





QAction * defAction = button->defaultAction();
if ( defAction )
{
  QString strShortcuts;
  QKeySequence keySequence;
  QList<QKeySequence> lstShortcuts = defAction->shortcuts();
  foreach(keySequence, lstShortcuts)
  {
    QString strShortcutString = keySequence.toString();
    if ( strShortcuts != "" )
      strShortcuts += ", ";
    strShortcuts += strShortcutString;
  }
  if ( strShortcuts != "" )
  {
    if ( strTitleText != "" )
      strTitleText += " (" + strShortcuts + ")";
    else
      strTipText += " (" + strShortcuts + ")";
  }
}

In the first tooltip there is invalid border if title is too large.

And I noticed that I place this post to wrong forum ;-(. Please move it to correct or remove this post at all if you will place this feature to your code.
Attachments:

Please Log in or Create an account to join the conversation.

More
  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Moderators: Developer MachinesEduard
Time to create page: 0.138 seconds

Developer Newsletter

Join our Developer Machines newsletter to get informed on all the latest releases of the commercial components for Qt.C++, Delphi FireMonkey, updates and general knowledges.

Quick Support

Should you need any additional information about our products or licensing, please contact us at the following email addresses:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

Get in Touch

If you would like to purchase our products or services, but don’t know how to do it the right way, please feel free to contact us:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.( any questions related to our products or services )
  • This email address is being protected from spambots. You need JavaScript enabled to view it.( questions related to licensing )