diff --git a/examples/quick/controls/gallery/content/Layouts.qml b/examples/quick/controls/gallery/content/Layouts.qml index 1251947ac0edc65dfc4f8a43cf66b14d0cbe280b..ac0a53a33dbb8d4440621e63645a8d94313fc8fc 100644 --- a/examples/quick/controls/gallery/content/Layouts.qml +++ b/examples/quick/controls/gallery/content/Layouts.qml @@ -76,7 +76,6 @@ Item { GridLayout { id: gridLayout anchors.fill: parent - anchors.margins: 4 rows: 3 flow: GridLayout.TopToBottom diff --git a/src/controls/GroupBox.qml b/src/controls/GroupBox.qml index 9bf1c0cc5bdb88039e29fe4eafb0954d0264dbb7..4aa6a50f4463e511301acddc2324a24ffcd7dc2d 100644 --- a/src/controls/GroupBox.qml +++ b/src/controls/GroupBox.qml @@ -159,7 +159,8 @@ Item { /*! \internal */ property alias __style: styleLoader.item - implicitWidth: (!anchors.fill ? container.calcWidth() : 0) + loader.leftMargin + loader.rightMargin + implicitWidth: Math.max((!anchors.fill ? container.calcWidth() : 0) + loader.leftMargin + loader.rightMargin, + sizeHint.implicitWidth + (checkable ? 24 : 6)) implicitHeight: (!anchors.fill ? container.calcHeight() : 0) + loader.topMargin + loader.bottomMargin Layout.minimumWidth: implicitWidth @@ -181,6 +182,7 @@ Item { property int rightMargin: __style ? __style.padding.right : 0 sourceComponent: styleLoader.item ? styleLoader.item.panel : null onLoaded: item.z = -1 + Text { id: sizeHint ; visible: false ; text: title } Loader { id: styleLoader property alias __control: groupbox diff --git a/src/private/qquickcontrolsettings.cpp b/src/private/qquickcontrolsettings.cpp index 44db49c209c1fe5e5f82491d14bdff41f0810897..e2daa17fa450d022c1fa3daf655bb127a33edef5 100644 --- a/src/private/qquickcontrolsettings.cpp +++ b/src/private/qquickcontrolsettings.cpp @@ -133,4 +133,15 @@ QString QQuickControlSettings::styleFilePath() const return m_path + QLatin1Char('/') + m_name; } +extern Q_GUI_EXPORT int qt_defaultDpiX(); + +qreal QQuickControlSettings::dpiScaleFactor() const +{ +#ifndef Q_OS_MAC + return (qreal(qt_defaultDpiX()) / 96.0); +#endif + return 1.0; +} + + QT_END_NAMESPACE diff --git a/src/private/qquickcontrolsettings_p.h b/src/private/qquickcontrolsettings_p.h index 98e8515124805c1d57fb77b13ca89331b421c594..8ff0ecbf5ca53abf65e4167a4475c00cc57cffb1 100644 --- a/src/private/qquickcontrolsettings_p.h +++ b/src/private/qquickcontrolsettings_p.h @@ -55,6 +55,7 @@ class QQuickControlSettings : public QObject Q_PROPERTY(QUrl style READ style NOTIFY styleChanged) Q_PROPERTY(QString styleName READ styleName WRITE setStyleName NOTIFY styleNameChanged) Q_PROPERTY(QString stylePath READ stylePath WRITE setStylePath NOTIFY stylePathChanged) + Q_PROPERTY(qreal dpiScaleFactor READ dpiScaleFactor CONSTANT) public: QQuickControlSettings(QQmlEngine *engine); @@ -67,6 +68,8 @@ public: QString stylePath() const; void setStylePath(const QString &path); + qreal dpiScaleFactor() const; + signals: void styleChanged(); void styleNameChanged(); diff --git a/src/styles/Desktop/GroupBoxStyle.qml b/src/styles/Desktop/GroupBoxStyle.qml index 3c4bfc43e119fc65acf66dd3618d86a219e0ae9a..2348e66316ac10941ad0389d89f0af25b7355e80 100644 --- a/src/styles/Desktop/GroupBoxStyle.qml +++ b/src/styles/Desktop/GroupBoxStyle.qml @@ -55,10 +55,10 @@ PaddedStyle { } padding { - top: (control.title.length > 0 || control.checkable ? titleHeight : 0) + 6 - left: 8 - right: 8 - bottom: 6 + top: Math.round(Settings.dpiScaleFactor * (control.title.length > 0 || control.checkable ? titleHeight : 0) + (style.style == "mac" ? 9 : 6)) + left: Math.round(Settings.dpiScaleFactor * 8) + right: Math.round(Settings.dpiScaleFactor * 8) + bottom: Math.round(Settings.dpiScaleFactor * 7 + (style.style.indexOf("windows") > -1 ? 2 : 0)) } property Component panel: StyleItem {