本文整理汇总了C++中QAccessibleInterface::relationTo方法的典型用法代码示例。如果您正苦于以下问题:C++ QAccessibleInterface::relationTo方法的具体用法?C++ QAccessibleInterface::relationTo怎么用?C++ QAccessibleInterface::relationTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAccessibleInterface
的用法示例。
在下文中一共展示了QAccessibleInterface::relationTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: navigate
/*! \reimp */
int QAccessibleWidget::navigate(RelationFlag relation, int entry,
QAccessibleInterface **target) const
{
if (!target)
return -1;
*target = 0;
QObject *targetObject = 0;
QWidgetList childList = childWidgets(widget());
bool complexWidget = childList.size() < childCount();
switch (relation) {
// Hierarchical
case Self:
targetObject = object();
break;
case Child:
if (complexWidget) {
if (entry > 0 && entry <= childCount())
return entry;
return -1;
}else {
if (entry > 0 && childList.size() >= entry)
targetObject = childList.at(entry - 1);
}
break;
case Ancestor:
{
if (entry <= 0)
return -1;
targetObject = widget()->parentWidget();
int i;
for (i = entry; i > 1 && targetObject; --i)
targetObject = targetObject->parent();
if (!targetObject && i == 1)
targetObject = qApp;
}
break;
case Sibling:
{
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(parentObject());
if (!iface)
return -1;
iface->navigate(Child, entry, target);
delete iface;
if (*target)
return 0;
}
break;
// Geometrical
case QAccessible::Left:
if (complexWidget && entry) {
if (entry < 2 || widget()->height() > widget()->width() + 20) // looks vertical
return -1;
return entry - 1;
}
// fall through
case QAccessible::Right:
if (complexWidget && entry) {
if (entry >= childCount() || widget()->height() > widget()->width() + 20) // looks vertical
return -1;
return entry + 1;
}
// fall through
case QAccessible::Up:
if (complexWidget && entry) {
if (entry < 2 || widget()->width() > widget()->height() + 20) // looks horizontal
return - 1;
return entry - 1;
}
// fall through
case QAccessible::Down:
if (complexWidget && entry) {
if (entry >= childCount() || widget()->width() > widget()->height() + 20) // looks horizontal
return - 1;
return entry + 1;
} else {
QAccessibleInterface *pIface = QAccessible::queryAccessibleInterface(parentObject());
if (!pIface)
return -1;
QRect startg = rect(0);
QPoint startc = startg.center();
QAccessibleInterface *candidate = 0;
int mindist = 100000;
int sibCount = pIface->childCount();
for (int i = 0; i < sibCount; ++i) {
QAccessibleInterface *sibling = 0;
pIface->navigate(Child, i+1, &sibling);
Q_ASSERT(sibling);
if ((relationTo(0, sibling, 0) & Self) || (sibling->state(0) & QAccessible::Invisible)) {
//ignore ourself and invisible siblings
delete sibling;
continue;
}
//.........这里部分代码省略.........