Details
-
Bug
-
Resolution: Incomplete
-
P3: Somewhat important
-
None
-
5.9.6
-
None
Description
This is weird... Unfortunately I cannot give all my code and I have no time to create new for reproduce. Read this and ask me for all details.
I create application with mixed C++ model and QML view. The view implemented inside QQuickWidget. Model can have many different changes (it has about 20 drawable different fields) and therefore I reset it's context property after each change by call to
rootContext()->setContextProperty("ModelList", QVariant::fromValue(sheet));
To keep view position on the list I use non-common solution. When flicking movement stops ListView sends signal
Item {
id: iItem
signal sendIndex(int index)
function getIndex( index ){ lView.positionViewAtIndex( index, ListView.Beginning ) }
...
ListView {
id: iView
...
onMovementEnded: lItem.sendIndex( indexAt(1,contentY) )
...
In C++ code I get this signal to slot and store index. Later when model calls setContextProperty() for this list root object - it sends signal with previously stored index to this object. This signal reaches function getIndex( index ) and restores view position. All this works fine in several cases except one.
When model only reorders internally: no new items appear, no any items removed, just only one item changes and model sorts respectively - then view first draws as needed with stored item index first. But after second-two it suddenly draws list again from beginning. In all other cases this does not happen - if model lost items or some were added then list draws properly with first item which index was stored. Twice redraw happiness only when model keeps size. Changed item index before change always is greater and remains greater than first item view index (after sort changed item always goes down in list). And what is most frustrating - when view jumps to beginning - NO onMovementEnded event emits. During experiments I found that signal QQuickWidget::statusChanged( QQuickWidget::Ready ) emits after second model change. That means - when I setContextProperty() and then change positionViewAtIndex() then if model had added or removed items - then QQuickWidget::statusChanged( QQuickWidget::Ready ) emits once. But if the model was just reordered with it's size kept - then QQuickWidget::statusChanged( QQuickWidget::Ready ) emits twice. Looks like in this case internal QML engine twice processes this model.