Op 16-10-2013 15:04, Igor Mironchik schreef:
Forgot to say that I use
d->m_sortModel->setDynamicSortFilter(false);
because of dynamic sorting moves the rows with the same value in a
sorted column in its sole discretion from time to time.
Still, here is your problem. The problem is that appearantly, by
default, QSortFilterProxyModel does not use a stable sort algoritm. I'd
reimplement QSFPM to use a stable algorithm instead.
André
Hi.
I use QTreeView to display dynamic data. I.e. rows can be inserted
during program execution dynamically and values in some column can be
changed dynamically too. But I need QTreeView to be sorted by the
given by user column when new rows added.
I've connected to the rowsInserted signal:
connect(d->m_model,
SIGNAL( rowsInserted( const QModelIndex &, int, int ) ),
this, SLOT( rowsAdded( QModelIndex, int, int ) ) );
And in the slot I do the next:
void
ChannelView::rowsAdded( const QModelIndex & parent, int start, int end
)
{
Q_UNUSED( parent )
Q_UNUSED( start )
Q_UNUSED( end )
qDebug() << "SORT" << parent << start << end;
d->m_sortModel->sort( d->m_sortModel->sortColumn(),
d->m_sortModel->sortOrder() );
}
But I see that QTreeView doesn't sorted by the given column when the data in
that column is static.
In the debug print I see the next:
SORT QModelIndex(-1,-1,0x0,QObject(0x0)) 0 -1
SORT QModelIndex(-1,-1,0x0,QObject(0x0)) 0 0
SORT QModelIndex(-1,-1,0x0,QObject(0x0)) 1 1
SORT QModelIndex(-1,-1,0x0,QObject(0x0)) 2 2
I've inserted three rows only but rowsInserted emitted four times. Why?
What am I doing wrong?
Thanks.
--
Best Regards,
Igor Mironchik.
--
Best Regards,
Igor Mironchik.
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
--
You like Qt?
I am looking for collegues to join me at i-Optics!
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest