#include <QString>
#include <QMap>
#include <QRegExp>
#include <QMapIterator>
int main () {
QFile file("../MOVE QWidget/gamefiles/hiScores.txt");
QMap<int,QString> fileMap;
while ( !txt.atEnd() ) {
rx.indexIn(line);
int number = rx.cap(1).toInt();
fileMap.insert(number,line);
}
QMapIterator<int,QString> i(fileMap);
i.toBack();
while ( i.hasPrevious()) {
i.previous();
std::cout<<i.key()<<" ";
}
}
file.close();
}
#include <QString>
#include <QMap>
#include <QRegExp>
#include <QMapIterator>
int main () {
QFile file("../MOVE QWidget/gamefiles/hiScores.txt");
QMap<int,QString> fileMap;
if (file.open(QIODevice::ReadOnly)) {
QTextStream txt(&file);
QRegExp rx("(^[0-9]+)");
while ( !txt.atEnd() ) {
QString line =txt.readLine();
rx.indexIn(line);
int number = rx.cap(1).toInt();
fileMap.insert(number,line);
}
QMapIterator<int,QString> i(fileMap);
i.toBack();
while ( i.hasPrevious()) {
i.previous();
std::cout<<i.key()<<" ";
}
}
file.close();
}
To copy to clipboard, switch view to plain text mode
Ok, thanks a lot for your help!
As you see, i go through first advice of calhal.
code snippet of course in 'CODE' tags ;-)
Bookmarks