Code: Alles auswählen
#ifndef LIST_H
#define LIST_H
#include <QList>
#include <QtAlgorithms>
template <typename T>
class List : public QList<T>
{
public:
inline List() : QList<T>() {}
inline List(const List<T> &l) : QList<T>(l) {}
inline List(const QList<T> &l) : QList<T>(l) {}
bool less_than(int index1, int index2);
List<int> create_index();
private:
QList<int> m_index;
};
template <typename T>
bool List<T>::less_than(int index1, int index2) { return (this->at(m_index[index1]) < this->at(m_index[index2])); }
template <typename T>
List<int> List<T>::create_index()
{
int i;
for (i = 0; i < this->size(); i++)
{
m_index << i;
}
less_than(0,0);
qSort(m_index.begin(), m_index.end(), this->less_than);
List<int> index(m_index);
m_index.clear();
return index;
};
#endifCode: Alles auswählen
In file included from music_manager.cpp:6:0:
list.h: In member function ‘List<int> List<T>::create_index() [with T = QString]’:
music_manager.cpp:46:35: instantiated from here
list.h:60:5: error: no matching function for call to ‘qSort(QList<int>::iterator, QList<int>::iterator, <unresolved overloaded function type>)’
/usr/include/QtCore/qalgorithms.h:209:13: note: candidate is: void qSort(RandomAccessIterator, RandomAccessIterator, LessThan) [with RandomAccessIterator = QList<int>::iterator, LessThan = bool (List<QString>::*)(int, int)]