I use qLowerBound to find an item in a QList
, but this function returns an iterator, while I need an index (I'll pass it to another function that expects an index). Is there a way to get the index from the QList
iterator?
You can subtract iterator to beginning of your list from your iterator to get an index, since pointer arithmetic is defined on iterators:
int idx = iter-yourList.begin();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.