本文整理汇总了C++中QAccessibleInterface::child方法的典型用法代码示例。如果您正苦于以下问题:C++ QAccessibleInterface::child方法的具体用法?C++ QAccessibleInterface::child怎么用?C++ QAccessibleInterface::child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAccessibleInterface
的用法示例。
在下文中一共展示了QAccessibleInterface::child方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: hitTest
void tst_QQuickAccessible::hitTest()
{
QQuickView *window = new QQuickView;
window->setSource(testFileUrl("hittest.qml"));
window->show();
QAccessibleInterface *windowIface = QAccessible::queryAccessibleInterface(window);
QVERIFY(windowIface);
QAccessibleInterface *rootItem = windowIface->child(0);
QRect rootRect = rootItem->rect();
// check the root item from app
QAccessibleInterface *appIface = QAccessible::queryAccessibleInterface(qApp);
QVERIFY(appIface);
QAccessibleInterface *itemHit = appIface->childAt(rootRect.x() + 200, rootRect.y() + 50);
QVERIFY(itemHit);
QCOMPARE(itemHit->rect(), rootRect);
QAccessibleInterface *rootItemIface;
for (int c = 0; c < rootItem->childCount(); ++c) {
QAccessibleInterface *iface = rootItem->child(c);
QString name = iface->text(QAccessible::Name);
if (name == QLatin1String("rect1")) {
// hit rect1
QAccessibleInterface *rect1 = iface;
QRect rect1Rect = rect1->rect();
QAccessibleInterface *rootItemIface = rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10);
QVERIFY(rootItemIface);
QCOMPARE(rect1Rect, rootItemIface->rect());
QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect1"));
// should also work from top level (app)
QAccessibleInterface *app(QAccessible::queryAccessibleInterface(qApp));
QAccessibleInterface *itemHit2(topLevelChildAt(app, rect1Rect.x() + 10, rect1Rect.y() + 10));
QVERIFY(itemHit2);
QCOMPARE(itemHit2->rect(), rect1Rect);
QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1"));
} else if (name == QLatin1String("rect2")) {
QAccessibleInterface *rect2 = iface;
// FIXME: This is seems broken on OS X
// QCOMPARE(rect2->rect().translated(rootItem->rect().x(), rootItem->rect().y()), QRect(0, 50, 100, 100));
QAccessibleInterface *rect20 = rect2->child(0);
QVERIFY(rect20);
QCOMPARE(rect20->text(QAccessible::Name), QLatin1String("rect20"));
QPoint p = rect20->rect().bottomRight() + QPoint(20, 20);
QAccessibleInterface *rect201 = rect20->childAt(p.x(), p.y());
QVERIFY(rect201);
QCOMPARE(rect201->text(QAccessible::Name), QLatin1String("rect201"));
rootItemIface = topLevelChildAt(windowIface, p.x(), p.y());
QVERIFY(rootItemIface);
QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect201"));
}
}
delete window;
QTestAccessibility::clearEvents();
}
示例3: hitTest
void tst_QQuickAccessible::hitTest()
{
QQuickView *window = new QQuickView;
window->setSource(testFileUrl("hittest.qml"));
window->show();
QAccessibleInterface *windowIface = QAccessible::queryAccessibleInterface(window);
QVERIFY(windowIface);
QAccessibleInterface *rootItem = windowIface->child(0);
QRect rootRect = rootItem->rect();
// check the root item from app
QAccessibleInterface *appIface = QAccessible::queryAccessibleInterface(qApp);
QVERIFY(appIface);
QAccessibleInterface *itemHit(appIface->childAt(rootRect.x() + 200, rootRect.y() + 50));
QVERIFY(itemHit);
QCOMPARE(rootRect, itemHit->rect());
// hit rect1
QAccessibleInterface *rect1(rootItem->child(0));
QRect rect1Rect = rect1->rect();
QAccessibleInterface *rootItemIface = rootItem->childAt(rect1Rect.x() + 10, rect1Rect.y() + 10);
QVERIFY(rootItemIface);
QCOMPARE(rect1Rect, rootItemIface->rect());
QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect1"));
// should also work from top level (app)
QAccessibleInterface *app(QAccessible::queryAccessibleInterface(qApp));
QAccessibleInterface *itemHit2(topLevelChildAt(app, rect1Rect.x() + 10, rect1Rect.y() + 10));
QVERIFY(itemHit2);
QCOMPARE(itemHit2->rect(), rect1Rect);
QCOMPARE(itemHit2->text(QAccessible::Name), QLatin1String("rect1"));
// hit rect201
QAccessibleInterface *rect2(rootItem->child(1));
QVERIFY(rect2);
// FIXME: This is seems broken on mac
// QCOMPARE(rect2->rect().translated(rootItem->rect().x(), rootItem->rect().y()), QRect(0, 50, 100, 100));
QAccessibleInterface *rect20(rect2->child(0));
QVERIFY(rect20);
QAccessibleInterface *rect201(rect20->child(1));
QVERIFY(rect201);
QRect rect201Rect = rect201->rect();
rootItemIface = windowIface->childAt(rect201Rect.x() + 20, rect201Rect.y() + 20);
QVERIFY(rootItemIface);
QCOMPARE(rootItemIface->rect(), rect201Rect);
QCOMPARE(rootItemIface->text(QAccessible::Name), QLatin1String("rect201"));
delete window;
QTestAccessibility::clearEvents();
}
示例4: 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();
}
示例5: childIdListForAccessibleObject
static jintArray childIdListForAccessibleObject(JNIEnv *env, jobject /*thiz*/, jint objectId)
{
QAccessibleInterface *iface = interfaceFromId(objectId);
if (iface) {
jintArray jArray = env->NewIntArray(jsize(iface->childCount()));
for (int i = 0; i < iface->childCount(); ++i) {
QAccessibleInterface *child = iface->child(i);
if (child) {
QAccessible::Id ifaceId = QAccessible::uniqueId(child);
jint jid = ifaceId;
env->SetIntArrayRegion(jArray, i, 1, &jid);
}
}
return jArray;
}
return env->NewIntArray(jsize(0));
}
示例6: Test
/*
Recursiveley navigates the accessible hiearchy looking for an interface that
passsed the Test (meaning it returns true).
*/
QAccessibleInterface *WidgetNavigator::recursiveSearch(TestBase *test, QAccessibleInterface *iface)
{
QStack<QAccessibleInterface *> todoInterfaces;
todoInterfaces.push(iface);
while (todoInterfaces.isEmpty() == false) {
QAccessibleInterface *testInterface = todoInterfaces.pop();
if ((*test)(testInterface))
return testInterface;
const int numChildren = testInterface->childCount();
for (int i = 0; i < numChildren; ++i) {
QAccessibleInterface *childInterface = testInterface->child(i);
if (childInterface) {
todoInterfaces.push(childInterface);
}
}
}
return 0;
}
示例7: checkableTest
void tst_QQuickAccessible::checkableTest()
{
QScopedPointer<QQuickView> window(new QQuickView());
window->setSource(testFileUrl("checkbuttons.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 *root = iface->child(0);
QAccessibleInterface *button1 = root->child(0);
QCOMPARE(button1->role(), QAccessible::Button);
QVERIFY(!(button1->state().checked));
QVERIFY(!(button1->state().checkable));
QVERIFY(button1->state().focusable);
QVERIFY(!button1->state().focused);
QTestAccessibility::clearEvents();
// set properties
QQuickItem *button1item = qobject_cast<QQuickItem*>(rootItem->childItems().at(0));
QVERIFY(button1item);
QCOMPARE(button1item->objectName(), QLatin1String("button1"));
button1item->forceActiveFocus();
QVERIFY(button1->state().focusable);
QVERIFY(button1->state().focused);
QAccessibleEvent focusEvent(button1item, QAccessible::Focus);
QVERIFY_EVENT(&focusEvent);
QAccessibleInterface *button2 = root->child(1);
QVERIFY(!(button2->state().checked));
QVERIFY(button2->state().checkable);
QQuickItem *button2item = qobject_cast<QQuickItem*>(rootItem->childItems().at(1));
QVERIFY(button2item);
QCOMPARE(button2item->objectName(), QLatin1String("button2"));
QAccessibleInterface *button3 = root->child(2);
QVERIFY(button3->state().checked);
QVERIFY(button3->state().checkable);
QAccessibleInterface *checkBox1 = root->child(3);
QCOMPARE(checkBox1->role(), QAccessible::CheckBox);
QVERIFY(checkBox1->state().checked);
QVERIFY(checkBox1->state().checkable);
QQuickItem *checkbox1item = qobject_cast<QQuickItem*>(rootItem->childItems().at(3));
QVERIFY(checkbox1item);
QCOMPARE(checkbox1item->objectName(), QLatin1String("checkbox1"));
checkbox1item->setProperty("checked", false);
QVERIFY(!checkBox1->state().checked);
QAccessible::State checkState;
checkState.checked = true;
QAccessibleStateChangeEvent checkChanged(checkbox1item, checkState);
QVERIFY_EVENT(&checkChanged);
checkbox1item->setProperty("checked", true);
QVERIFY(checkBox1->state().checked);
QVERIFY_EVENT(&checkChanged);
QAccessibleInterface *checkBox2 = root->child(4);
QVERIFY(!(checkBox2->state().checked));
QVERIFY(checkBox2->state().checkable);
QTestAccessibility::clearEvents();
}