Add an accessible role to an existing class
-
Hi,
I'm trying to add an accessible role to an existing class.
For example, a role tree in a class of type QTreeWidget
There is a way to do this without rewrite all code to create an accessible class?
I readed all examples of qtbase/src/widget/accessible but I sucess nothing when I trying to use it on my existing app :( -
Hi,
I'm trying to add an accessible role to an existing class.
For example, a role tree in a class of type QTreeWidget
There is a way to do this without rewrite all code to create an accessible class?
I readed all examples of qtbase/src/widget/accessible but I sucess nothing when I trying to use it on my existing app :(@Oreonan
for items widgets (which QTreeWidget is) the accesible data is coming from the model data -
@Oreonan
a little bit more information would be helpful in order to help you
https://doc.qt.io/qt-5/qt.html#ItemDataRole-enum
There is noQt::AccessibleRolevalue for example, but aQt::AccessibleTextRole -
@Oreonan
what do you mean with that? -
I have a model representing a tree with 2 columns, one for item name, one for state (enabled/disabled). I want to set an accessible role to checkbox because I think like this a screen reader can be able to say if an item is enabled or disabled. Currently I use the accessible text role to do that but it's not a good solution for me.
-
I have a model representing a tree with 2 columns, one for item name, one for state (enabled/disabled). I want to set an accessible role to checkbox because I think like this a screen reader can be able to say if an item is enabled or disabled. Currently I use the accessible text role to do that but it's not a good solution for me.
-
It's representing by a QModel with 2 columns and using Qt::DisplayRole, here is a part of code:
case Qt::DisplayRole : if(orientation == Qt::Horizontal) { switch(section) { case COLUMN_NAME: return tr("Event"); case COLUMN_CHECK: return tr("Enabled"); } } break; case Qt::DisplayRole : if (index.column() == COLUMN_CHECK) return (m_ttsselected & m_ttsevents[index.row()])? tr("Enabled") : tr("Disabled"); Q_ASSERT(index.column() == COLUMN_NAME); switch(m_ttsevents[index.row()]) { case TTS_USER_LOGGEDIN : return tr("User logged in"); case TTS_USER_LOGGEDOUT : return tr("User logged out"); //... -
@Oreonan
a little bit more information would be helpful in order to help you
https://doc.qt.io/qt-5/qt.html#ItemDataRole-enum
There is noQt::AccessibleRolevalue for example, but aQt::AccessibleTextRoleHi,
As suggested by @raven-worx
@raven-worx said in Add an accessible role to an existing class:Qt::AccessibleTextRole
Why not return the values you want for that role ?
-
I have a model representing a tree with 2 columns, one for item name, one for state (enabled/disabled). I want to set an accessible role to checkbox because I think like this a screen reader can be able to say if an item is enabled or disabled. Currently I use the accessible text role to do that but it's not a good solution for me.
@Oreonan said in Add an accessible role to an existing class:
I have a model representing a tree with 2 columns, one for item name, one for state (enabled/disabled). I want to set an accessible role to checkbox because I think like this a screen reader can be able to say if an item is enabled or disabled. Currently I use the accessible text role to do that but it's not a good solution for me.
i haven't used the accessible framework for a while, but i think you will have to create a custom accessible interface (plugin or in source) for your tree widget to represent the checkbox in the interface