diff options
author | Santhosh Kumar <santhosh.kumar.selvaraj@qt.io> | 2022-10-17 16:19:38 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-10-31 14:07:34 +0000 |
commit | 60d31a301a19d11d5a4666b4ad76fbec658e4940 (patch) | |
tree | 7506ee0b2e972d814e4d6920d1246632e2feb4de | |
parent | b576aa6263780b6718ba811bd79887682e9d694b (diff) |
Fix implicit size in qml button
If minimum size of the button is negative, then its value is ignored
while computing implicit width and height.
Removed below warning message from QML buttons:
“QML Button: (StyleItem) implicit width is smaller than minimum width!"
Change-Id: I4b4464fe9e5914c598c5a2f438a985058eea1b06
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 6fdba5b2acd9b948107b831ee99e16b7637397db)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/quicknativestyle/qstyle/qquickcommonstyle.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/quicknativestyle/qstyle/qquickcommonstyle.cpp b/src/quicknativestyle/qstyle/qquickcommonstyle.cpp index 5c54a3bc1e..d8cac57486 100644 --- a/src/quicknativestyle/qstyle/qquickcommonstyle.cpp +++ b/src/quicknativestyle/qstyle/qquickcommonstyle.cpp @@ -4475,12 +4475,13 @@ int QCommonStyle::pixelMetric(PixelMetric m, const QStyleOption *opt) const QSize QCommonStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &csz) const { Q_D(const QCommonStyle); - QSize sz(csz); + QSize sz(!csz.isEmpty() ? csz : QSize(0,0)); + switch (ct) { case CT_PushButton: if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { - int w = csz.width(), - h = csz.height(), + int w = sz.width(), + h = sz.height(), bm = proxy()->pixelMetric(PM_ButtonMargin, btn), fw = proxy()->pixelMetric(PM_DefaultFrameWidth, btn) * 2; w += bm + fw; |