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
committerMitch Curtis <mitch.curtis@qt.io>2023-09-13 02:00:24 +0800
commitb1d53c599921ee18ecf2b825b8f7edec8556b099 (patch)
tree4db0097d8cb346e46784b759e526c04e2552717f /src/quickcontrols/basic/impl/qquickbasicprogressbar.cpp
parentdfa51fe0bcc4dafac454791e24e6bb4b919438d7 (diff)
Basic: fix progress bar color not changing when set
Fixes: QTBUG-116795 Pick-to: 6.5 6.6 Change-Id: Ic0ede8f2f34feba427e2354d2d8a4a915605a44b Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
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();
}