I'm having a problem. I can't seem to make the screen reader tell the shorcut keys along with the option's name for a QAction contained in a QMenu. For example instead of "Open...", I would like the screen reader to tell me "Open... Ctrl+O".
As I see it, the problem is that the screen reader only sees the QAction::text() property. So if I do something like this:
//I want to do something that is the equivalent of this two lines,
//but for QAction
fileMenu->setAccessibleName("File");
fileMenu->setAccessibleDescription("Alt+F");
openAction
->setShortcut
(QKeySequence::fromString("Ctrl+O"));
fileMenu->addAction(openAction);
menus->addMenu(fileMenu);
QMenuBar* menus = this->menuBar();
QMenu* fileMenu = new QMenu("&File", menus);
//I want to do something that is the equivalent of this two lines,
//but for QAction
fileMenu->setAccessibleName("File");
fileMenu->setAccessibleDescription("Alt+F");
QAction* openAction = new QAction("Open", fileMenu);
openAction->setShortcut(QKeySequence::fromString("Ctrl+O"));
fileMenu->addAction(openAction);
menus->addMenu(fileMenu);
To copy to clipboard, switch view to plain text mode
I get something like this:
example1.jpg
|File|
|Open Ctrl+O|
And the screen reader tells me for File "File Menu Alt+F", but for Open option just "Open".
If I try and do something like:
openAction->setText(openAction->text() + " " + openAction->shortcut().toString());
openAction->setText(openAction->text() + " " + openAction->shortcut().toString());
To copy to clipboard, switch view to plain text mode
I get something like this:
ex1.jpg
The screen-reader tells me now "Open Ctrl+O", but as you can see it duplicates the string for shortcut.
What I've tried so far: setting all the properties that I could see (for example QAction::setWhatsThis, QAction::setIconText, etc.)
I've found a small hack that I could use; I could do something like:
openAction->setText(openAction->text() + "\n\n\n"+ openAction->shortcut().toString());
openAction->setText(openAction->text() + "\n\n\n"+ openAction->shortcut().toString());
To copy to clipboard, switch view to plain text mode
But this cuts a bit from the top of the text ("Open"). So a way to allign the text in order for it not be cut when I use this hack would do for now.
ex2.png
I'm open to any suggestions. I think that there are ways to do this using the statusBar, but I don't know how. I hope I made myself clear... Thank you for your help!
Bookmarks