QTabBar disable auto shortcuts



  • Hi,

    I have an application which has a lot of shortcuts, many of them able to be specified by the user. For historical reasons, some of these shortcuts are Alt+<Key> based.

    Additionally, my application uses tabs as the primary interface, and I have run into an issue that I can't seem to work around.


    QTabBar seems to auto-magically create keyboard shortcuts for the tab, even though they do not have any & characters in them.

    For example, if I have two tabs with the text: Untitled and Untitled_1, the result is that the first tab is connected to a shortcut of Alt+U and the second is connected to Alt+1. This is in contrast to the documentation which says I should expect this behavior if the text was &Untitled and Untitled_&1.

    Also, QKeySequence::mnemonic is, in fact, returning an empty QKeySequence object for the tab text being provided; so I don't understand where these shortcuts are coming from :-/. I have tried playing with qt_set_sequence_auto_mnemonic to no success. If I wrap operations which create/update tabs with:

    qt_set_sequence_auto_mnemonic(false); 
    // do work
    qt_set_sequence_auto_mnemonic(true);
    

    I see no difference in behavior. Alternatively, if I just do qt_set_sequence_auto_mnemonic(false) at program start, this does seem to disable the shortcuts in the tabs... but also breaks all my menu shortcuts (dispite still displaying the underlines as if they would work!)

    Is there a solution that will let me disable these keyboard shortcuts in a QTabBar without me having to roll an entirely custom one?



  • I found the culprit, and it is not Qt's fault, it is KDE's!

    Apparently KDEPlatformTheme will automatically adjust accelerators... which personally, I don't like. It can be worked around with:

    [Development]
    AutoCheckAccelerators=false
    

    In ~/.config/kdeglobals

    I will look for a better solution, but in the KDE forums ;-).



  • Hi @Evan-Teran,

    Glad you found a workaround. It would nevertheless be nice to report back here when you get more information. Others may be interested in this topic also.

    Thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.