Results 1 to 3 of 3

Thread: Accessibility for QAction contained in QMenu

  1. #1
    Join Date
    May 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Accessibility for QAction contained in QMenu

    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:
    Qt Code:
    1. QMenuBar* menus = this->menuBar();
    2. QMenu* fileMenu = new QMenu("&File", menus);
    3. //I want to do something that is the equivalent of this two lines,
    4. //but for QAction
    5. fileMenu->setAccessibleName("File");
    6. fileMenu->setAccessibleDescription("Alt+F");
    7. QAction* openAction = new QAction("Open", fileMenu);
    8. openAction->setShortcut(QKeySequence::fromString("Ctrl+O"));
    9. fileMenu->addAction(openAction);
    10. 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:

    Qt Code:
    1. 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:

    Qt Code:
    1. 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!

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,396
    Thanks
    37
    Thanked 1,542 Times in 1,493 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Accessibility for QAction contained in QMenu

    Good question.
    This sounds like something that is not completely implemented yet. You could check the Qt issue tracker if there is an entry for that.

    For now it might be necessary to implement a form of accessibility wrapper for QAction using http://qt-project.org/doc/qt-5/qaccessibleobject.html

    It could also help to look into the Qt sources and check how QMenu it handles its accessibility. It might be easy to add the desired feature and submit it to the Qt project

    Cheers,
    _

  3. #3
    Join Date
    May 2014
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Accessibility for QAction contained in QMenu

    Thank you for your reply.
    I've submitted a bug report. It can be found here:
    https://bugreports.qt-project.org/browse/QTBUG-38915

Similar Threads

  1. Getting QMenu of selected QAction
    By snydesc in forum Qt Programming
    Replies: 1
    Last Post: 7th October 2012, 00:26
  2. QAction with QMenu click event
    By mero in forum Qt Programming
    Replies: 1
    Last Post: 15th July 2012, 10:49
  3. Can't disable a QAction in QMenu
    By punkypogo in forum Qt Programming
    Replies: 3
    Last Post: 10th August 2010, 14:07
  4. QAction text color (QMenu)
    By StefanK in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2009, 15:14
  5. QPushButton QMenu QAction
    By hgedek in forum Newbie
    Replies: 2
    Last Post: 1st November 2007, 12:29

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.