Re: Some trouble with QList<> and qsort
I hope somebody can help. I try to sort, but I get an error. :-(((
Code:
class FileEntry
{
public:
double size;
bool selected;
int index;
{
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...tains-POINTERS
Re: Some trouble with QList<> and qsort
having never used qsort before, all I can say is that its looking at the wrong footprint of qsort. What version of Qt are you running?
Re: Some trouble with QList<> and qsort
this
Code:
qsort(tmpList.begin(),tmpList.end(),lessSize);
tries to call C function
Code:
qsort(void* ptr, size_t count, size_t size_in_bytes, int (*compare_function)(const void*,const void*))
signature obviously does not match arguments provided.
Probably this is what you want
Code:
qSort(tmpList.begin(),tmpList.end(),lessSize);
Re: Some trouble with QList<> and qsort
I go back to the simple basic's std:sort() instead of qsort()...... and it works from the beginning-