1. This is QList<double> not QList<int>.
2. If you can not sort the list then you have to check each element and choose the one for which abs (value) is the smallest. If you only have positive values, you choose the smallest value (you do not need abs). Something like this (for positive only value) :
double s_value = list.at(0);
int s_index=0;
for(int i=1; i < list.size();i++)
{
if(list.at(i) < s_value)
{
s_value = list.at(i);
s_index = i;
}
}
double s_value = list.at(0);
int s_index=0;
for(int i=1; i < list.size();i++)
{
if(list.at(i) < s_value)
{
s_value = list.at(i);
s_index = i;
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks