本文整理汇总了C++中QList::lastIndexOf方法的典型用法代码示例。如果您正苦于以下问题:C++ QList::lastIndexOf方法的具体用法?C++ QList::lastIndexOf怎么用?C++ QList::lastIndexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QList
的用法示例。
在下文中一共展示了QList::lastIndexOf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lastIndexOf
void tst_QList::lastIndexOf() const
{
QList<QString> list;
list << "foo" << "bar" << "baz";
// one instance of the target item
QVERIFY(list.lastIndexOf(QLatin1String("baz")) == 2);
// shouldn't find this
QVERIFY(list.lastIndexOf(QLatin1String("shouldntfindme")) == -1);
// multiple instances
list.append("baz");
list.append("baz");
QVERIFY(list.lastIndexOf(QLatin1String("baz")) == 4);
// search from the middle to find the last one
QVERIFY(list.lastIndexOf(QLatin1String("baz"), 3) == 3);
// try find none
QVERIFY(list.lastIndexOf(QLatin1String("baz"), 1) == -1);
}
示例2: OptionalProperty
QList<OptionalProperty> KisNodeDelegate::Private::rightmostProperties(const KisBaseNode::PropertyList &props) const
{
QList<OptionalProperty> list;
QList<OptionalProperty> prependList;
list << OptionalProperty(0);
list << OptionalProperty(0);
list << OptionalProperty(0);
KisBaseNode::PropertyList::const_iterator it = props.constBegin();
KisBaseNode::PropertyList::const_iterator end = props.constEnd();
for (; it != end; ++it) {
if (!it->isMutable) continue;
if (it->id == KisLayerPropertiesIcons::visible.id()) {
// noop...
} else if (it->id == KisLayerPropertiesIcons::locked.id()) {
list[0] = OptionalProperty(&(*it));
} else if (it->id == KisLayerPropertiesIcons::inheritAlpha.id()) {
list[1] = OptionalProperty(&(*it));
} else if (it->id == KisLayerPropertiesIcons::alphaLocked.id()) {
list[2] = OptionalProperty(&(*it));
} else {
prependList.prepend(OptionalProperty(&(*it)));
}
}
{
QMutableListIterator<OptionalProperty> i(prependList);
i.toBack();
while (i.hasPrevious()) {
OptionalProperty val = i.previous();
int emptyIndex = list.lastIndexOf(0);
if (emptyIndex < 0) break;
list[emptyIndex] = val;
i.remove();
}
}
return prependList + list;
}