Skip to content

Instantly share code, notes, and snippets.

@lamprosg
Created January 23, 2013 12:10
Show Gist options
  • Select an option

  • Save lamprosg/4604903 to your computer and use it in GitHub Desktop.

Select an option

Save lamprosg/4604903 to your computer and use it in GitHub Desktop.
Qt - qFind algorithm
//How to use qFind()
#include "mytimer.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QList<int> List;
List << 1 << 5 << 15 << 23;
//qFind(starting point,ending point, value we're looking for)
QList<int>::const_iterator Iter = qFind(List.begin(),List.end(),15);
if (Iter != List.end()) //if it's not equal to the end of the list (23), then we found a value
{
int value = *Iter; //The value we found (15)
}
else
{
//Value not found, iter=List.end()
}
return a.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment