I am having some problems with the automatic keyboard shortcuts. I am using a Mac, where they seem to be disabled by default, so I call qt_set_sequence_auto_mnemonic to enable them. Consider the following code:
#include <QtGui>
#ifdef Q_WS_MAC
extern void qt_set_sequence_auto_mnemonic(bool b);
#endif
int main(int argv, char **args)
{
#ifdef Q_WS_MAC
qt_set_sequence_auto_mnemonic(true);
#endif
QObject::connect(&button,
SIGNAL(clicked
()),
qApp,
SLOT(quit
()));
button.show();
return app.exec();
}
#include <QtGui>
#ifdef Q_WS_MAC
extern void qt_set_sequence_auto_mnemonic(bool b);
#endif
int main(int argv, char **args)
{
#ifdef Q_WS_MAC
qt_set_sequence_auto_mnemonic(true);
#endif
QApplication app(argv, args);
QPushButton button("&test");
QObject::connect(&button, SIGNAL(clicked()), qApp, SLOT(quit()));
button.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
This opens a window with a single push button, which is activated by the keyboard shortcut Alt+t, which works fine. However, when I change the button label to "t&est", then activating the button by Alt+e does not work. Changing it to "te&st" allows me to activate the button using Alt+s.
It seems like there is something special about the keyboard combination Alt+e. After a little bit of trial and error, it seems like the keys that are used by OS X to enter accented characters (e, u, i, n) cannot be used a keyboard shortcuts.
Is this interpretation correct? Is there any workaround that would allow me to use consistent keyboard shortcuts across several platforms?
Thanks,
Lutz
Bookmarks