Reputation: 712
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
Upvotes: 4
Views: 2084
Reputation: 309
I'm not sure if this would work in your case with menu, but I solved mine where o->parent() returns QObject like this.
dynamic_cast<QWidget*>(o->parent())->setAccessibleName("whatever");
Upvotes: 0
Reputation: 13421
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
.
Upvotes: 1