@@ -477,6 +477,11 @@ void ListViewWithPageHeader::componentComplete()
477477 polish();
478478}
479479
480+static inline bool uFuzzyCompare(qreal r1, qreal r2)
481+{
482+ return qFuzzyCompare(r1, r2) || (qFuzzyIsNull(r1) && qFuzzyIsNull(r2));
483+}
484+
480485void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
481486{
482487 // Check we are not being taken down and don't paint anything
@@ -491,11 +496,7 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
491496 const bool showHeaderAnimationRunning = m_contentYAnimation->isRunning() && contentYAnimationType == ContentYAnimationShowHeader;
492497 if (m_headerItem) {
493498 const auto oldHeaderItemShownHeight = m_headerItemShownHeight;
494− if (contentY() < -m_minYExtent) {
495− // Stick the header item to the top when dragging down
496− m_headerItem->setY(contentY());
497− m_headerItem->setHeight(m_headerItem->implicitHeight() + (-m_minYExtent - contentY()));
498− } else {
499+ if (uFuzzyCompare(contentY(), -m_minYExtent) || contentY() > -m_minYExtent) {
499500 m_headerItem->setHeight(m_headerItem->implicitHeight());
500501 // We are going down (but it's not because of the rebound at the end)
501502 // (but the header was not shown by it's own position)
@@ -509,21 +510,32 @@ void ListViewWithPageHeader::viewportMoved(Qt::Orientations orient)
509510 m_headerItemShownHeight = 0;
510511 m_headerItem->setY(-m_minYExtent);
511512 } else if ((scrolledUp && notRebounding && notShownByItsOwn && !maximizeVisibleAreaRunning) || (m_headerItemShownHeight > 0) || m_inContentHeightKeepHeaderShown) {
512− if (maximizeVisibleAreaRunning && diff > 0) // If we are maximizing and the header was shown, make sure we hide it
513+ if (maximizeVisibleAreaRunning && diff > 0) {
514+ // If we are maximizing and the header was shown, make sure we hide it
513515 m_headerItemShownHeight -= diff;
514− else
516+ } else {
515517 m_headerItemShownHeight += diff;
516− if (contentY() == -m_minYExtent) {
518+ }
519+ if (uFuzzyCompare(contentY(), -m_minYExtent)) {
517520 m_headerItemShownHeight = 0;
518521 } else {
519522 m_headerItemShownHeight = qBound(static_cast<qreal>(0.), m_headerItemShownHeight, m_headerItem->height());
520523 }
521524 if (m_headerItemShownHeight > 0) {
522− m_headerItem->setY(contentY() - m_headerItem->height() + m_headerItemShownHeight);
525+ if (uFuzzyCompare(m_headerItem->height(), m_headerItemShownHeight)) {
526+ m_headerItem->setY(contentY());
527+ m_headerItemShownHeight = m_headerItem->height();
528+ } else {
529+ m_headerItem->setY(contentY() - m_headerItem->height() + m_headerItemShownHeight);
530+ }
523531 } else {
524532 m_headerItem->setY(-m_minYExtent);
525533 }
526534 }
535+ } else {
536+ // Stick the header item to the top when dragging down
537+ m_headerItem->setY(contentY());
538+ m_headerItem->setHeight(m_headerItem->implicitHeight() + (-m_minYExtent - contentY()));
527539 }
528540 // We will be changing the clip item, need to accomadate for it
529541 // otherwise we move the firstItem down/up twice (unless the
@@ -1264,6 +1276,11 @@ void ListViewWithPageHeader::updatePolish()
12641276 refill();
12651277
12661278 if (m_contentHeightDirty) {
1279+ // We need to make sure all bindings have updated otherwise
1280+ // we may end up with bindings updating when we call setContentHeight
1281+ // and then everything gets out of sync, i.e. testHeaderPositionBug1240118
1282+ qApp->processEvents();
1283+
12671284 qreal contentHeight;
12681285 if (m_visibleItems.isEmpty()) {
12691286 contentHeight = m_headerItem ? m_headerItem->height() : 0;