Well... It's an intermittent problem, I have to insist on table generation a few times in order to see it happening. I tried using the following:
ui->tableWidget->setSortingEnabled(false);
//add data
ui->tableWidget->setSortingEnabled(true);
ui->tableWidget->setSortingEnabled(false);
//add data
ui->tableWidget->setSortingEnabled(true);
To copy to clipboard, switch view to plain text mode
I'm not sure if this method changes the dynamicSortFilter parameter in QSortFilterProxyModel. After a few tries the problem happened again, but now the application also crashes when I close the window after observing the blank rows. When I don't see the blank rows it closes without any issue.
I'm populating this table in two steps. In the first step I have the data to fill only one column, but I'm still creating all the empty QTableWidgetItems for the whole table. In the second step I'm only updating the remaining QTableWidgetItem with setText() or setData(). I'm disabling and enabling sorting before and after each step.
I'm suspecting that the problem is not with the data model, but while drawing the table graphics. I'm saying this because I cannot select the blank rows and after sorting they simply vanish.
Added after 4 minutes:
The only other weird thing I'm seeing in this QTableWidget happens when I call 'QTableWidget->setItem()' at the first time and then I receive the following errors in application output:
QObject::connect: Cannot queue arguments of type 'QVector<int>'
(Make sure 'QVector<int>' is registered using qRegisterMetaType().)
QObject::connect: Cannot queue arguments of type 'QVector<int>'
(Make sure 'QVector<int>' is registered using qRegisterMetaType().)
QObject::connect: Cannot queue arguments of type 'QVector<int>'
(Make sure 'QVector<int>' is registered using qRegisterMetaType().)
QObject::connect: Cannot queue arguments of type 'QVector<int>'
(Make sure 'QVector<int>' is registered using qRegisterMetaType().)
QObject::connect: Cannot queue arguments of type 'QVector<int>'
(Make sure 'QVector<int>' is registered using qRegisterMetaType().)
I don't how it could be related, maybe a coincidence, but I'm setting a QString:
QString nextSufix
= nextVariable.
OID.
right(nextVariable.
OID.
size() - this
->OIDs.
first().
size());
//add hidden column for index/sufix
QString nextSufix = nextVariable.OID.right(nextVariable.OID.size() - this->OIDs.first().size());
//add hidden column for index/sufix
ui->tableWidget->setItem(row, 0, new QTableWidgetItem(nextSufix));
To copy to clipboard, switch view to plain text mode
Bookmarks