Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.11.1
-
None
Description
I use QSortFilterProxyModel in QComboBox with insertPolicy = InsertAtBottom. I fill the model of 2 rows: the first one will be filtered and the second row is OK. So the combobox list of items contains one row. After insertion a new item I get the empty first row (instead of the old item) and the new item in the second row (it's OK).
The bug is in QSortFilterProxyModel::insertRows method, in lines:
int source_row = (row >= m->source_rows.count()
? m->source_rows.count()
: m->source_rows.at(row));
must be:
int source_row = (row >= m->source_rows.count()
? m->proxy_rows.count()
: m->source_rows.at(row));
That is because later in QSortFilterProxyModelPrivate::source_items_inserted method there is a line:
source_to_proxy.insert(start, delta_item_count, -1);
Here start is source_row of previous code (that is m->source_rows.count()) and source_to_proxy is m->proxy_rows.
So, in my example, in my source model, there will be inserted an empty item at index position 1 (instead of 2), and then there will be changed Qt::DisplayRole data at index position 2.
Attachments
Gerrit Reviews
For Gerrit Dashboard: QTBUG-69158 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
233670,11 | QSortFilterProxyModel: add test for inserting via a QComboBox | 5.11 | qt/qtbase | Status: ABANDONED | -1 | 0 |
235931,8 | QSortFilterProxyModel inserting at bottom of source model | 5.11 | qt/qtbase | Status: MERGED | +2 | 0 |
238614,5 | QSortFilterProxyModel: add test for inserting via a QComboBox | 5.12 | qt/qtbase | Status: MERGED | +2 | 0 |