本文整理汇总了C++中QAccessibleInterface::role方法的典型用法代码示例。如果您正苦于以下问题:C++ QAccessibleInterface::role方法的具体用法?C++ QAccessibleInterface::role怎么用?C++ QAccessibleInterface::role使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAccessibleInterface
的用法示例。
在下文中一共展示了QAccessibleInterface::role方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: get_accRole
// moz: [important]
HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::get_accRole(VARIANT varID, VARIANT *pvarRole)
{
QAccessibleInterface *accessible = accessibleInterface();
accessibleDebugClientCalls(accessible);
if (!accessible)
return E_FAIL;
QAccessible::Role role;
if (varID.lVal) {
QAccessibleInterface *child = childPointer(accessible, varID);
if (!child)
return E_FAIL;
role = child->role();
} else {
role = accessible->role();
}
if (role != QAccessible::NoRole) {
if (role >= QAccessible::LayeredPane) {
// This block should hopefully only be entered if the AT client
// does not support IAccessible2, since it should prefer IA2::role() then.
if (role == QAccessible::LayeredPane)
role = QAccessible::Pane;
else
role = QAccessible::Client;
}
(*pvarRole).vt = VT_I4;
(*pvarRole).lVal = role;
} else {
(*pvarRole).vt = VT_EMPTY;
}
return S_OK;
}
示例2: basicPropertiesTest
void tst_QQuickAccessible::basicPropertiesTest()
{
QAccessibleInterface *app = QAccessible::queryAccessibleInterface(qApp);
QCOMPARE(app->childCount(), 0);
QQuickView *window = new QQuickView();
window->setSource(testFileUrl("statictext.qml"));
window->show();
QCOMPARE(app->childCount(), 1);
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(window);
QVERIFY(iface);
QCOMPARE(iface->childCount(), 1);
QAccessibleInterface *item = iface->child(0);
QVERIFY(item);
QCOMPARE(item->childCount(), 2);
QCOMPARE(item->rect().size(), QSize(400, 400));
QCOMPARE(item->role(), QAccessible::Client);
QCOMPARE(iface->indexOfChild(item), 0);
QAccessibleInterface *text = item->child(0);
QVERIFY(text);
QCOMPARE(text->childCount(), 0);
QCOMPARE(text->text(QAccessible::Name), QLatin1String("Hello Accessibility"));
QCOMPARE(text->rect().size(), QSize(200, 50));
QCOMPARE(text->rect().x(), item->rect().x() + 100);
QCOMPARE(text->rect().y(), item->rect().y() + 20);
QCOMPARE(text->role(), QAccessible::StaticText);
QCOMPARE(item->indexOfChild(text), 0);
QAccessibleInterface *text2 = item->child(1);
QVERIFY(text2);
QCOMPARE(text2->childCount(), 0);
QCOMPARE(text2->text(QAccessible::Name), QLatin1String("The Hello 2 accessible text"));
QCOMPARE(text2->rect().size(), QSize(100, 40));
QCOMPARE(text2->rect().x(), item->rect().x() + 100);
QCOMPARE(text2->rect().y(), item->rect().y() + 40);
QCOMPARE(text2->role(), QAccessible::StaticText);
QCOMPARE(item->indexOfChild(text2), 1);
QCOMPARE(iface->indexOfChild(text2), -1);
QCOMPARE(text2->indexOfChild(item), -1);
delete window;
QTestAccessibility::clearEvents();
}
示例3: ignoredTest
void tst_QQuickAccessible::ignoredTest()
{
QScopedPointer<QQuickView> window(new QQuickView());
window->setSource(testFileUrl("ignored.qml"));
window->show();
QQuickItem *contentItem = window->contentItem();
QVERIFY(contentItem);
QQuickItem *rootItem = contentItem->childItems().first();
QVERIFY(rootItem);
// the window becomes active
QAccessible::State activatedChange;
activatedChange.active = true;
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(window.data());
QVERIFY(iface);
QAccessibleInterface *rectangleA = iface->child(0);
QCOMPARE(rectangleA->role(), QAccessible::StaticText);
QCOMPARE(rectangleA->text(QAccessible::Name), QLatin1String("A"));
static const char *expected = "BEFIHD";
// check if node "C" and "G" is skipped and that the order is as expected.
for (int i = 0; i < rectangleA->childCount(); ++i) {
QAccessibleInterface *child = rectangleA->child(i);
QCOMPARE(child->text(QAccessible::Name), QString(QLatin1Char(expected[i])));
}
QTestAccessibility::clearEvents();
}
示例4: parentId
static jint parentId(JNIEnv */*env*/, jobject /*thiz*/, jint objectId)
{
QAccessibleInterface *iface = interfaceFromId(objectId);
if (iface) {
QAccessibleInterface *parent = iface->parent();
if (parent) {
if (parent->role() == QAccessible::Application)
return -1;
return QAccessible::uniqueId(parent);
}
}
return -1;
}
示例5: get_accRole
HRESULT STDMETHODCALLTYPE QWindowsAccessible::get_accRole(VARIANT varID, VARIANT *pvarRole)
{
#ifdef DEBUG_SHOW_ATCLIENT_COMMANDS
showDebug(__FUNCTION__, accessible);
#endif //DEBUG_SHOW_ATCLIENT_COMMANDS
if (!accessible->isValid())
return E_FAIL;
Role role = accessible->role(varID.lVal);
if (role != NoRole) {
(*pvarRole).vt = VT_I4;
(*pvarRole).lVal = role;
} else {
(*pvarRole).vt = VT_EMPTY;
}
return S_OK;
}
示例6: role
/*! \reimp */
QAccessible::Role QAccessibleWidget::role(int child) const
{
if (!child)
return d->role;
QWidgetList childList = childWidgets(widget());
if (childList.count() > 0 && child <= childList.count()) {
QWidget *targetWidget = childList.at(child - 1);
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(targetWidget);
if (iface) {
QAccessible::Role role = iface->role(0);
delete iface;
return role;
}
}
return NoRole;
}
示例7: modelChange
void QAccessibleTable::modelChange(QAccessibleTableModelChangeEvent *event)
{
// if there is no cache yet, we don't update anything
if (childToId.isEmpty())
return;
switch (event->modelChangeType()) {
case QAccessibleTableModelChangeEvent::ModelReset:
Q_FOREACH (QAccessible::Id id, childToId)
QAccessible::deleteAccessibleInterface(id);
childToId.clear();
break;
// rows are inserted: move every row after that
case QAccessibleTableModelChangeEvent::RowsInserted:
case QAccessibleTableModelChangeEvent::ColumnsInserted: {
int newRows = event->lastRow() - event->firstRow() + 1;
int newColumns = event->lastColumn() - event->firstColumn() + 1;
ChildCache newCache;
ChildCache::ConstIterator iter = childToId.constBegin();
while (iter != childToId.constEnd()) {
QAccessible::Id id = iter.value();
QAccessibleInterface *iface = QAccessible::accessibleInterface(id);
Q_ASSERT(iface);
if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) {
Q_ASSERT(iface->tableCellInterface());
QAccessibleTableCell *cell = static_cast<QAccessibleTableCell*>(iface->tableCellInterface());
if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsInserted
&& cell->m_index.row() >= event->firstRow()) {
int newRow = cell->m_index.row() + newRows;
cell->m_index = cell->m_index.sibling(newRow, cell->m_index.column());
} else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::ColumnsInserted
&& cell->m_index.column() >= event->firstColumn()) {
int newColumn = cell->m_index.column() + newColumns;
cell->m_index = cell->m_index.sibling(cell->m_index.row(), newColumn);
}
} else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsInserted
&& iface->role() == QAccessible::RowHeader) {
QAccessibleTableHeaderCell *cell = static_cast<QAccessibleTableHeaderCell*>(iface);
if (cell->index >= event->firstRow()) {
cell->index += newRows;
}
} else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::ColumnsInserted
&& iface->role() == QAccessible::ColumnHeader) {
QAccessibleTableHeaderCell *cell = static_cast<QAccessibleTableHeaderCell*>(iface);
if (cell->index >= event->firstColumn()) {
cell->index += newColumns;
}
}
if (indexOfChild(iface) >= 0) {
newCache.insert(indexOfChild(iface), id);
} else {
// ### This should really not happen,
// but it might if the view has a root index set.
// This needs to be fixed.
QAccessible::deleteAccessibleInterface(id);
}
++iter;
}
childToId = newCache;
break;
}
case QAccessibleTableModelChangeEvent::ColumnsRemoved:
case QAccessibleTableModelChangeEvent::RowsRemoved: {
int deletedColumns = event->lastColumn() - event->firstColumn() + 1;
int deletedRows = event->lastRow() - event->firstRow() + 1;
ChildCache newCache;
ChildCache::ConstIterator iter = childToId.constBegin();
while (iter != childToId.constEnd()) {
QAccessible::Id id = iter.value();
QAccessibleInterface *iface = QAccessible::accessibleInterface(id);
Q_ASSERT(iface);
if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) {
Q_ASSERT(iface->tableCellInterface());
QAccessibleTableCell *cell = static_cast<QAccessibleTableCell*>(iface->tableCellInterface());
if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsRemoved) {
if (cell->m_index.row() < event->firstRow()) {
newCache.insert(indexOfChild(cell), id);
} else if (cell->m_index.row() > event->lastRow()) {
int newRow = cell->m_index.row() - deletedRows;
cell->m_index = cell->m_index.sibling(newRow, cell->m_index.column());
newCache.insert(indexOfChild(cell), id);
} else {
QAccessible::deleteAccessibleInterface(id);
}
} else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::ColumnsRemoved) {
if (cell->m_index.column() < event->firstColumn()) {
newCache.insert(indexOfChild(cell), id);
} else if (cell->m_index.column() > event->lastColumn()) {
int newColumn = cell->m_index.column() - deletedColumns;
cell->m_index = cell->m_index.sibling(cell->m_index.row(), newColumn);
newCache.insert(indexOfChild(cell), id);
} else {
QAccessible::deleteAccessibleInterface(id);
}
}
} else if (event->modelChangeType() == QAccessibleTableModelChangeEvent::RowsRemoved
//.........这里部分代码省略.........