aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2023-09-08 16:20:08 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-09-15 09:01:31 +0000
commit3c685b0c7403e84ba801944d287eb26f24bbee5a (patch)
tree4e999cd97f2e0a92c64913d5ae00acfb2b2da76e /src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp
parent86e6addc4b49e9f2696cd504fb1ce786a44dd3ad (diff)
Basic: fix progress bar color not changing when set
Fixes: QTBUG-116795 Change-Id: Ic0ede8f2f34feba427e2354d2d8a4a915605a44b Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io> (cherry picked from commit b1d53c599921ee18ecf2b825b8f7edec8556b099) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 0049856352a15330b6733ad6cb69139c4bc5ec5d)
Diffstat (limited to 'src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp')
-rw-r--r--src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp b/src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp
index 69d34f4e0f..1da27fa0aa 100644
--- a/src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp
+++ b/src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp
@@ -143,7 +143,6 @@ void QQuickBasicProgressBarNode::sync(QQuickItem *item)
QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode*>(transformNode->firstChild());
if (!rectNode) {
rectNode = d->sceneGraphContext()->createInternalRectangleNode();
- rectNode->setColor(bar->color());
transformNode->appendChildNode(rectNode);
}
@@ -151,6 +150,9 @@ void QQuickBasicProgressBarNode::sync(QQuickItem *item)
m.translate(blockStartX(i), 0);
transformNode->setMatrix(m);
+ // Set the color here too in case it was set after component completion,
+ // as updateCurrentTime doesn't sync it.
+ rectNode->setColor(bar->color());
rectNode->setRect(QRectF(QPointF(0, 0), QSizeF(BlockWidth, item->implicitHeight())));
rectNode->update();
@@ -165,10 +167,12 @@ void QQuickBasicProgressBarNode::sync(QQuickItem *item)
QSGInternalRectangleNode *rectNode = static_cast<QSGInternalRectangleNode *>(firstChild());
if (!rectNode) {
rectNode = d->sceneGraphContext()->createInternalRectangleNode();
- rectNode->setColor(bar->color());
appendChildNode(rectNode);
}
+ // Always set the color, not just when creating the rectangle node, so that we respect
+ // changes that are made after component completion.
+ rectNode->setColor(bar->color());
rectNode->setRect(QRectF(QPointF(0, 0), QSizeF(bar->progress() * item->width(), item->implicitHeight())));
rectNode->update();
}