My model was working wit a QStringList, each QString was a row, Name;Type;Company;etc... then i was using section() to get the data for each row cell. I've replaced the QStringList with QList<QStrngList>, i didn't know that section() were too slow, but with QList<QStringList> and using just MyListQSList.at(index.row()).at( column-nuber ) is very fast, just instantly:
QVariant rs_GameModel
::data(const QModelIndex &index,
int role
) const { //////////////////////////////////////////////////////////// DATA if (!index.isValid()) {
}
if (index.row() >= romCount || index.row() < 0 ) {
}
if (role == Qt::TextAlignmentRole) {
if (index.column() > 0 && index.column() < 10) {
return Qt::AlignHCenter;
}
}
if (role == Qt::UserRole) {
if (index.column() == 0) {
return QString("%1;%2;%3").
arg(ROMs.
at(index.
row()).
at(12)).
arg(ROMs.
at(index.
row()).
at(14)).
arg(ROMs.
at(index.
row()).
at(15));
}
if (index.column() == 3) {
ROMs.at(index.row()).at(11);
}
}
if (role == Qt::DecorationRole) {
if (index.column() == 0) {
return romicon;
}
if (index.column() == 2) {
return QPixmap(QString("Skin/%1/icons/sys/rate%1.png").
arg(CurrSkin
));
}
}
if (role == Qt::DisplayRole) {
if (index.column() == 0) {
return ROMs.at(index.row()).at(0);
}
if (index.column() == 3) {
if (ROMs.at(index.row()).at(3) != "rsnull") {
return ROMs.at(index.row()).at(3);
} else {
return cEmulator;
}
}
if (index.column() == 4) {
return ROMs.at(index.row()).at(4);
}
if (index.column() == 5) {
return ROMs.at(index.row()).at(5);
}
if (index.column() == 6) {
return ROMs.at(index.row()).at(6);
}
if (index.column() == 7) {
return ROMs.at(index.row()).at(7);
}
if (index.column() == 8) {
return ROMs.at(index.row()).at(8);
}
if (index.column() == 9) {
return ROMs.at(index.row()).at(9);
}
if (index.column() == 11) {
return ROMs.at(index.row()).at(10);
}
}
}
QVariant rs_GameModel::data(const QModelIndex &index, int role) const { //////////////////////////////////////////////////////////// DATA
if (!index.isValid()) {
return QVariant();
}
if (index.row() >= romCount || index.row() < 0 ) {
return QVariant();
}
if (role == Qt::TextAlignmentRole) {
if (index.column() > 0 && index.column() < 10) {
return Qt::AlignHCenter;
}
}
if (role == Qt::UserRole) {
if (index.column() == 0) {
return QString("%1;%2;%3").arg(ROMs.at(index.row()).at(12)).arg(ROMs.at(index.row()).at(14)).arg(ROMs.at(index.row()).at(15));
}
if (index.column() == 3) {
ROMs.at(index.row()).at(11);
}
}
if (role == Qt::DecorationRole) {
if (index.column() == 0) {
return romicon;
}
if (index.column() == 2) {
return QPixmap(QString("Skin/%1/icons/sys/rate%1.png").arg(CurrSkin));
}
}
if (role == Qt::DisplayRole) {
if (index.column() == 0) {
return ROMs.at(index.row()).at(0);
}
if (index.column() == 3) {
if (ROMs.at(index.row()).at(3) != "rsnull") {
return ROMs.at(index.row()).at(3);
} else {
return cEmulator;
}
}
if (index.column() == 4) {
return ROMs.at(index.row()).at(4);
}
if (index.column() == 5) {
return ROMs.at(index.row()).at(5);
}
if (index.column() == 6) {
return ROMs.at(index.row()).at(6);
}
if (index.column() == 7) {
return ROMs.at(index.row()).at(7);
}
if (index.column() == 8) {
return ROMs.at(index.row()).at(8);
}
if (index.column() == 9) {
return ROMs.at(index.row()).at(9);
}
if (index.column() == 11) {
return ROMs.at(index.row()).at(10);
}
}
return QVariant();
}
To copy to clipboard, switch view to plain text mode
I suposse will discover what is fast and what is slow in qt with the time, and programmng wit it
Bookmarks