tags:

views:

36

answers:

1

Hi,

I'm trying to set the accessible properties of a QMenu's sub items. I can set the accessible property of the parent menu using setAccessibleName() since it inherits QWidget. Unfortunately, the QActions that you add to the menu aren't widgets child classes, they inherit QObject directly.

Is there a way to set the menu items accessible name?

Thanks

+1  A: 

I've never used this aspect of Qt but it looks like you have to use the QAccessibleInterface framework. There is a subclass of this for QObject, namely QAccessibleObject. This still has some pure methods from the base so you'll need to provide some methods.

From what I can gather from a quick look at the documentation you can either provide a QAccessibleObject wrapper for the whole menu or for each action individually. If doing the latter then you would implement childCount() to return 0 and role(int i) to return QAccessible::MenuItem.

Troubadour
That sounds more promising than anything I was able to find. I was investigating the possibility of using QAction::associatedWidgets() to maybe get access to whatever graphical widget might be used to draw the menu item/action and get/set accessible info that way but that will probably only point you back to the QMenu.
Arnold Spence
I tried this, and it does just point back to the parent menu.
abudker
I'm going to attempt the idea contained in the actual answer, but it feels like this should be a whole lot easier...
abudker
@abudker: If it's any consolation then I agree :)
Troubadour