cit
25th July 2014, 21:46
I hope somebody can help. I try to sort, but I get an error. :-(((
class FileEntry
{
public:
QString name;
QString absolutePath;
QString relativePath;
double size;
QString typ;
QDateTime createDate;
bool selected;
int index;
FileEntry(QString pName, QString pAbsolutePath,QString pRelativePath,double pSize,QString pTyp,QDateTime pCreateDate,bool pSelected,int pIndex)
{
name = pName;
absolutePath =pAbsolutePath;
relativePath=pRelativePath;
size=pSize;
typ=pTyp;
createDate=pCreateDate;
selected=pSelected;
index = pIndex;
}
};
bool lessSize(const FileEntry& a, const FileEntry& b)
{
return a.size < b.size;
}
void DoSelection()
{
QList<FileEntry> tmpList;
tmpList.append(FileEntry("A","A","A",2.2,"A",QDateTime(),false,1));
tmpList.append(FileEntry("A","A","A",2.2,"A",QDateTime(),false,1));
qsort(tmpList.begin(),tmpList.end(),lessSize);
}
I get these error:
error: cannot convert 'QList<FileEntry>::iterator' to 'void*' for argument '1' to 'void qsort(void*, size_t, size_t, __compar_fn_t)'
qsort(tmpList.begin(),tmpList.end(),lessSize);
Thx.Cit
I tried the way from this post.....
http://www.qtcentre.org/threads/9485-Sorting-using-qSort%28%29-if-QList-contains-POINTERS
class FileEntry
{
public:
QString name;
QString absolutePath;
QString relativePath;
double size;
QString typ;
QDateTime createDate;
bool selected;
int index;
FileEntry(QString pName, QString pAbsolutePath,QString pRelativePath,double pSize,QString pTyp,QDateTime pCreateDate,bool pSelected,int pIndex)
{
name = pName;
absolutePath =pAbsolutePath;
relativePath=pRelativePath;
size=pSize;
typ=pTyp;
createDate=pCreateDate;
selected=pSelected;
index = pIndex;
}
};
bool lessSize(const FileEntry& a, const FileEntry& b)
{
return a.size < b.size;
}
void DoSelection()
{
QList<FileEntry> tmpList;
tmpList.append(FileEntry("A","A","A",2.2,"A",QDateTime(),false,1));
tmpList.append(FileEntry("A","A","A",2.2,"A",QDateTime(),false,1));
qsort(tmpList.begin(),tmpList.end(),lessSize);
}
I get these error:
error: cannot convert 'QList<FileEntry>::iterator' to 'void*' for argument '1' to 'void qsort(void*, size_t, size_t, __compar_fn_t)'
qsort(tmpList.begin(),tmpList.end(),lessSize);
Thx.Cit
I tried the way from this post.....
http://www.qtcentre.org/threads/9485-Sorting-using-qSort%28%29-if-QList-contains-POINTERS