Is it possible to disable shortcuts usage for a widget?
-
Hi,
I have a descendant class from QTabBar. It works fine but I need some buttons to have an ampersand (&) symbol in title. When I use this symbol it automatically makes next letter a shortcut. But this behaviour disturbs other things and I would like to switch this option. But I have no idea is it feasible or not.Yes, I know that I may put double && and it will be converted into a single one without shortcut. But it disturbs things in another place - I use the same string in different places and this extra ampersand also bad for me. I.e. I'll need to have 2 copies of each string - with single and double ampersands.
Does anyone know better/simler way to prevent QTabBar from creating shortcuts?
-
@StarterKit said in Is it possible to disable shortcuts usage for a widget?:
Yes, I know that I may put double && and it will be converted into a single one without shortcut. But it disturbs things in another place - I use the same string in different places and this extra ampersand also bad for me. I.e. I'll need to have 2 copies of each string - with single and double ampersands.
This is the only correct thing to do. You do not (should not) want to solve your issue by disabling shortcuts.
-
Or write a small function which removes the ampersand when you retrieve the text for the tabbars.
-
@Christian-Ehrlicher exactly :) Finally I overrode
AddTab
method to duble&
in incoming strings. -
@StarterKit said in Is it possible to disable shortcuts usage for a widget?:
Finally I overrode
AddTab
method to duble&
in incoming strings.I did not suggest this because it means you cannot deliberately set any shortcut for any tab item. So long as you are happy with that behaviour then it is OK. @Christian-Ehrlicher's suggestion does not suffer from this issue, since you would only substitute
&&
to&
, leaving any deliberate shortcuts in place. As you please.