jane
24th May 2006, 11:44
Hi, I've got a problem using qSort, when I reimplement LessThan :
In my Vertical class:
QList<Plane *> Vertical::planes; //static list of Plane objects
bool lessThan( const Plane *plane1, const Plane *plane2)
{
Plane *me = Vertical::getPlanes().at(0);
return(plane1->close(me->getPosition()) < plane2->close(me->getPosition()));
}
void Vertical::sortL(const QString &str)
{
QList <Plane *> list;
qCopy(planes.begin()+1, planes.end(), list.begin());
qSort(list.begin(), list.end(),lessThan);
.......
}
QList<Plane *> Vertical::getPlanes() {
return planes;
}
and in the Plane class :
double Plane::close(const QPoint &p) const
{
return (sqrt((double)((p.x()-position.x())^2 + (p.y()-position.y())^2)));
}
And the compiler says that qsort does not look as a function that takes 2 arguments, and gives me some lines number erros in qalgorithms.h
Any ideas ???
In my Vertical class:
QList<Plane *> Vertical::planes; //static list of Plane objects
bool lessThan( const Plane *plane1, const Plane *plane2)
{
Plane *me = Vertical::getPlanes().at(0);
return(plane1->close(me->getPosition()) < plane2->close(me->getPosition()));
}
void Vertical::sortL(const QString &str)
{
QList <Plane *> list;
qCopy(planes.begin()+1, planes.end(), list.begin());
qSort(list.begin(), list.end(),lessThan);
.......
}
QList<Plane *> Vertical::getPlanes() {
return planes;
}
and in the Plane class :
double Plane::close(const QPoint &p) const
{
return (sqrt((double)((p.x()-position.x())^2 + (p.y()-position.y())^2)));
}
And the compiler says that qsort does not look as a function that takes 2 arguments, and gives me some lines number erros in qalgorithms.h
Any ideas ???