I have periodically action to insert a single rows in existing QTableList.
Problem is that inserted row does not display items correctly in the right place.
I think it only happens when QtableList has set.
this->sortItems( 1, Qt::AscendingOrder );
this->sortItems( 1, Qt::AscendingOrder );
To copy to clipboard, switch view to plain text mode
When I remove sorting new rows appears on the bottom and all row items are displayed just find.
This is how I do it.
void ListView::insertRowFile(File *file) {
DEBUG;
int row = this->rowCount();
this->setRowCount(row+1);
dateItem->setText(file->FileDate().toString("MM-dd-yyyy hh:mm"));
this->setItem(row, col, dateItem);
nameItem->setIcon(file->FileIcon());
dateItem->setText(file->FileName());
this->setItem(row, col, nameItem);
}
void ListView::insertRowFile(File *file) {
DEBUG;
int row = this->rowCount();
this->setRowCount(row+1);
QTableWidgetItem *dateItem = new QTableWidgetItem;
dateItem->setText(file->FileDate().toString("MM-dd-yyyy hh:mm"));
this->setItem(row, col, dateItem);
QTableWidgetItem *nameItem = new QTableWidgetItem;
nameItem->setIcon(file->FileIcon());
dateItem->setText(file->FileName());
this->setItem(row, col, nameItem);
}
To copy to clipboard, switch view to plain text mode
I have tried also
this->insertRow(row);
this->insertRow(row);
To copy to clipboard, switch view to plain text mode
instead of
this->setRowCount(row+1);
this->setRowCount(row+1);
To copy to clipboard, switch view to plain text mode
I set sortItems after displaying all rows in initial list construct.
What is a proper way to use insertRow with column sorting enabled ?
Thank You
Bookmarks