aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickcontainer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicktemplates2/qquickcontainer.cpp')
-rw-r--r--src/quicktemplates2/qquickcontainer.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp
index 2c357f82..609c2079 100644
--- a/src/quicktemplates2/qquickcontainer.cpp
+++ b/src/quicktemplates2/qquickcontainer.cpp
@@ -294,8 +294,9 @@ void QQuickContainerPrivate::removeItem(int index, QQuickItem *item)
updatingCurrent = true;
+ int count = contentModel->count();
bool currentChanged = false;
- if (index == currentIndex) {
+ if (index == currentIndex && (index != 0 || count == 1)) {
q->setCurrentIndex(currentIndex - 1);
} else if (index < currentIndex) {
--currentIndex;
@@ -305,10 +306,10 @@ void QQuickContainerPrivate::removeItem(int index, QQuickItem *item)
QQuickItemPrivate::get(item)->removeItemChangeListener(this, changeTypes);
item->setParentItem(nullptr);
contentModel->remove(index);
+ --count;
q->itemRemoved(index, item);
- int count = contentModel->count();
for (int i = index; i < count; ++i)
q->itemMoved(i, itemAt(i));