View Full Version : Accessible menus

13th August 2009, 14:42
Hi all,

I'm struggling to make a menu accessible as the QMenu::addAction() generates a QAction object based on QObject that does not have the accessibility options.

I understand that there is a QAccessibleObject, but I have no idea how to create a QAction based on it.

Without using the setAccessibleName() function, there is no way for my Qt app to pass information to my screen reader; so my menu is completely silent.

Does anyone know how to do this?



13th August 2009, 14:47
You can use:

QMetaObject * QObject::metaObject ()

13th August 2009, 17:19
Thank for the pointer yogeshgokul, but I'm not quite sure how to use QMetaObject in this case.

Here's a snippet that I'm trying to convert:

MenuButton = new QPushButton(this);
QMenu* MenuButtonPopup = new QMenu(MenuButton);
MenuButtonPopup->addAction( tr( "An item" ), this, SLOT(Clicked()))->setAccessibleName( tr( "An Item" ) );

Unsuprisingly this fails to compile with:

'setAccessibleName' : is not a member of 'QAction'

Is there a way to get QAction to inherit the setAccessibleName() function, or do I have to reimplement both QMenu and QAction?

17th August 2009, 10:30
Unsuprisingly this fails to compile with:

'setAccessibleName' : is not a member of 'QAction'

Yes, this is clear, this is not a member. You can create a new property in designer and set it, access it in code.