summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Sutterud <lars.sutterud@qt.io>2023-11-14 10:01:35 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-11-14 14:32:49 +0000
commit697a12f91166b3985756113bc9f88825f2ecc9ea (patch)
treecc6271b975b57c6b287348e71b23660b6ceb2b2f
parent6b39152c02ca5ad393db6db595317359d84f3761 (diff)
Media Player Example: Set volume slider minimum width to default size
This change fixes a design bug where decreasing the window width would decrease the volume slider width gradually down to zero. A volume slider needs a certain width to be useful, therefore the default slider width from QSlider::sizeHint() is now used as its minimum size. This is done by changing its horizontol QSizePolicy to MinimumExpanded. As a result the volume slider now has a constant width, which is the same apprach used in e.g. Apple Music and VLC player. Fixes: QTBUG-119087 Pick-to: 6.5 6.2 5.15 Change-Id: Ibe93b278f2651d4aa3a5c0ce7316dad27c2776e5 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 96e0b1338dff1f186966cbb2159e9399d78234c2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--examples/multimedia/player/playercontrols.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/examples/multimedia/player/playercontrols.cpp b/examples/multimedia/player/playercontrols.cpp
index 67db0c76b..d0c8c52d3 100644
--- a/examples/multimedia/player/playercontrols.cpp
+++ b/examples/multimedia/player/playercontrols.cpp
@@ -40,6 +40,9 @@ PlayerControls::PlayerControls(QWidget *parent) : QWidget(parent)
m_volumeSlider = new QSlider(Qt::Horizontal, this);
m_volumeSlider->setRange(0, 100);
+ QSizePolicy sp = m_volumeSlider->sizePolicy();
+ sp.setHorizontalPolicy(QSizePolicy::MinimumExpanding);
+ m_volumeSlider->setSizePolicy(sp);
connect(m_volumeSlider, &QSlider::valueChanged, this,
&PlayerControls::onVolumeSliderValueChanged);