Hi everyone!
I want to do custom sorting with a QList (its a list of pointers so the sorting has to be custom...)
I followed the doc and wrote:
bool QBsdPortGlobal::lessThan(QBsdPort* p1, QBsdPort* p2);
{
return p1->origin() < p2->origin();
}
bool QBsdPortGlobal::lessThan(QBsdPort* p1, QBsdPort* p2);
{
return p1->origin() < p2->origin();
}
To copy to clipboard, switch view to plain text mode
but whenver I call
qSort(m_collection.begin(),
m_collection.end(),
lessThan);
qSort(m_collection.begin(),
m_collection.end(),
lessThan);
To copy to clipboard, switch view to plain text mode
I get:
bsdportglobal.cpp:497: error: no matching function for call to 'qSort(QList<QBsdPort*>::iterator, QList<QBsdPort*>::iterator, <unresolved overloaded function type>)'
/usr/local/include/qt4/QtCore/qalgorithms.h:203: note: candidates are: void qSort(RandomAccessIterator, RandomAccessIterator, LessThan) [with RandomAccessIterator = QList<QBsdPort*>::iterator, LessThan = bool (QBsdPortGlobal::*)(QBsdPort*, QBsdPort*)]
bsdportglobal.cpp:497: error: no matching function for call to 'qSort(QList<QBsdPort*>::iterator, QList<QBsdPort*>::iterator, <unresolved overloaded function type>)'
/usr/local/include/qt4/QtCore/qalgorithms.h:203: note: candidates are: void qSort(RandomAccessIterator, RandomAccessIterator, LessThan) [with RandomAccessIterator = QList<QBsdPort*>::iterator, LessThan = bool (QBsdPortGlobal::*)(QBsdPort*, QBsdPort*)]
To copy to clipboard, switch view to plain text mode
Why is lessThan() unresovled? I put it in the source and it is declared in the header. The fcuntion works otherwise...
Thanks for your help!
Bookmarks