I am using Qt 5.11.1 on Manjaro Linux.
When I open Qt Designer, create a new dialog and add stuff on the widget, Qt Designer adds '&' (ampersand) in the text in some types of widgets automatically. (Ampersand "&" is shortcut in Qt, commonly referred to as "mnemonic". For example, if text of button is "b&utton", I can click the button with Alt + U
. See this answer for more information.) For example, if I create a radio button and set the text to "button", the text will become "b&utton" automatically, and I cannot remove the '&'. What should I do?

- 470
- 3
- 10
-
Do nothing? What is the actual problem? Is & visible on running GUI? – hyde Jul 04 '18 at 11:30
-
1& is shortcut in Qt. For example, if the text is "b&utton", the 'u' is shown with underscore and '&' is not shown. But I don't want it. – cges30901 Jul 04 '18 at 12:22
-
The properties don't have shortcut definition? Sounds like there could be some "auto" setting as default. – hyde Jul 04 '18 at 12:35
-
2looks like https://stackoverflow.com/questions/32688153/how-to-disable-automatic-mnemonics-in-a-qt-application-on-kde – Andrii Jul 04 '18 at 12:52
-
1Why my question is downvoted? Can someone tell me how to improve my question? – cges30901 Jan 02 '19 at 04:56
-
I edited my question. Maybe this is better now? – cges30901 Jan 02 '19 at 06:20
2 Answers
Not sure, probably qt_set_sequence_auto_mnemonic function is what you are looking for.
Specifies whether mnemonics for menu items, labels, etc., should be honored or not. On Windows and X11, this feature is on by default; on macOS, it is off. When this feature is off (that is, when b is false), QKeySequence::mnemonic() always returns an empty string.
Note: This function is not declared in any of Qt's header files. To use it in your application, declare the function prototype before calling it.
-
Sorry, I don't know how to use it. But the workaround in https://stackoverflow.com/questions/32688153/how-to-disable-automatic-mnemonics-in-a-qt-application-on-kde works. Thank you very much for providing the link! – cges30901 Jul 05 '18 at 10:58
The workaroud in How to disable automatic mnemonics in a Qt application on KDE? works. Thank you Andrii for providing the link! The workaroud is to add
[Development]
AutoCheckAccelerators=false
to ~/.config/kdeglobals
.
I also found that removing the package kdelibs4support
is also a workaround, but some packages might depend on it.

- 470
- 3
- 10