PDA

View Full Version : QTableView/QStandardItem model bug?



gig-raf
29th March 2016, 12:46
Hope some can help me out here. I am trying to understand if what I am experiencing is a bug or a feature.

When I hide data in my QTableView and then do a select all [ctrl+a] followed by a delete all - the rows disappear also the ones that are currently hidden in the view? is that to be expected?

in a QTableView, with data kept in a QStandarditem model

I hide the rows like this;


for(int i = 0; i < lst.count(); i++) {
ui->playTableView->hideRow(lst.at(i)->row());
}

I then use the following code to get the content of one of the columns stored in every visible row;



if (ui->playTableView->selectionModel()->hasSelection()) {
QModelIndexList indexes = ui->playTableView->selectionModel()->selectedRows();
qSort(indexes.begin(), indexes.end());
for (int i = indexes.count() - 1; i > -1; --i) {
qDebug() << indexes[i];
}


So i.e. my view has one visible row, and 25 hidden rows. If I select all rows (1), and execute the code above it will print the QModelIndex of all 26 rows, but I expected only to get one (the one that was actually selected)

is this normal? or am I doing something wrong here?

I could of course check if the rows is hidden or not before I print, but I would have thought that it would be logical and already default behaviour in QT. 5

Thanks in advance.