From 11fa0e2656ba4f07fc8789e513a49b661bf3bc08 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 14 Mar 2019 09:06:08 +0100 Subject: Doc: update qtquickcontrols2.differences.qdoc Add SplitView and TableView. Change-Id: Ib049d12d6e922269ac80d2e9b10f37f5e274a567 Reviewed-by: Paul Wicking --- .../controls/doc/src/qtquickcontrols2-differences.qdoc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/imports/controls') diff --git a/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc index e30285de..40080840 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-differences.qdoc @@ -338,9 +338,19 @@ \li \row \li \l [QML QtQuickControls1] {SplitView} - \li \mdash - \li + \li \l [QML QtQuickControls2] {SplitView} \li + \li \list + \li \b {Qt Quick Controls 1}: Uses \l Layout attached properties + to specify size hints. + \li \b {Qt Quick Controls 2}: Uses dedicated + \l [QML QtQuickControls2] {SplitView} attached properties + to specify size hints. + Allows \l {SplitView::saveState()}{saving} and + \l {SplitView::restoreState()}{restoring} state. + Separate attached \l SplitHandle API for managing split + handles. + \endlist \row \li \l [QML QtQuickControls1] {StackView},\br \l [QML QtQuickControls1] {StackViewDelegate},\br @@ -377,7 +387,8 @@ \row \li \l [QML QtQuickControls1] {TableView} \li \mdash - \li + \li The new \l [QML QtQuick] {TableView} can be found in the Qt Quick + module. \li \row \li \l [QML QtQuickControls1] {TextArea} -- cgit v1.2.3 From 8b78d9cea3091b0bd94d1ae0c71a000f8e7e1903 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 18 Feb 2019 11:28:58 +0100 Subject: Fix DialogButtonBox content size calculation Some history: - f1f884d3 worked around an issue in DialogButtonBox. - c2fd8f7d fixed it by using contentWidth; i.e. the implicit width of the contentItem. It caused QTBUG-72372. - I tried to fix QTBUG-72372 with 6476de0b, but created (or exposed) QTBUG-73860. The problem in QTBUG-73860 can be seen with the following example: Dialog { id: dialog visible: true standardButtons: Dialog.Ok } The single 'Ok' button here will go outside of the dialog. The underlying issue can be seen by looking into DialogButtonBox.qml: implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, (control.count === 1 ? contentWidth * 2 : contentWidth) + leftPadding + rightPadding) implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, contentHeight + topPadding + bottomPadding) The implicit width of the box in this case is contentWidth * 2 (there is one button, so control.count === 1). This should result in the button taking half the width of the box and being aligned to the right: alignment: count === 1 ? Qt.AlignRight : undefined ... delegate: Button { width: control.count === 1 ? control.availableWidth / 2 : undefined } What actually happens is that the contentItem (ListView) is temporarily 0 until it gets its final size of 100. However, QQuickDialogButtonBox doesn't respond to this change in the ListView's contentWidth. This problem can be fixed by returning to c2fd8f7d's resizeContent() implementation, which uses contentWidth. Then, there is a second issue: Dialog { id: dialog visible: true standardButtons: Dialog.Ok width: 300 } The button here is also positioned outside of the box. The problem is that the contentWidth is based on implicitContentWidth: QQuickContainerPrivate::updateContentWidth() { // ... contentWidth = implicitContentWidth; // ... } implicitContentWidth is calculated by calling getContentWidth(): void QQuickControlPrivate::updateImplicitContentWidth() { // ... implicitContentWidth = getContentWidth(); // ... } In the case of horizontal alignment, QQuickDialogButtonBoxPrivate::getContentWidth() uses the implicit width of the largest button: for (int i = 0; i < count; ++i) { QQuickItem *item = q->itemAt(i); if (item) { totalWidth += item->implicitWidth(); maxWidth = qMax(maxWidth, item->implicitWidth()); } } // ... if ((alignment & Qt::AlignHorizontal_Mask) == 0) totalWidth = qMax(totalWidth, count * maxWidth + totalSpacing); The Default style button has an implicitWidth of 100. The DialogButtonBox in the example above is 300 pixels wide, so the button should be 150, and it is, thanks to its width binding. However, the DialogButtonBox uses contentWidth to size its contentItem (ListView), and the contentWidth is, as mentioned, 100: the implicit width of the button. So, the button ends up hanging over the side of the box, as it's larger than the box thinks it is. This problem is fixed by setting DialogButtonBox's contentWidth to the contentWidth of the contentItem (ListView). This makes DialogButtonBox use the explicit widths of the buttons rather than their implicit widths. Since the contentWidth is no longer implicit, we must also change any use of contentWidth in the implicitWidth binding to implicitContentWidth. While writing auto tests for this, they caught an issue where contentWidth wasn't updated, so now we call resizeContent() in QQuickContainer::setContentWidth(). Change-Id: I99ffda21b47aeb14d4382e453e87c4312f343a1c Fixes: QTBUG-72886 Fixes: QTBUG-73860 Reviewed-by: Richard Moe Gustavsen --- src/imports/controls/DialogButtonBox.qml | 5 +++-- src/imports/controls/universal/DialogButtonBox.qml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src/imports/controls') diff --git a/src/imports/controls/DialogButtonBox.qml b/src/imports/controls/DialogButtonBox.qml index 1b783b3b..3c9d5b48 100644 --- a/src/imports/controls/DialogButtonBox.qml +++ b/src/imports/controls/DialogButtonBox.qml @@ -41,9 +41,10 @@ T.DialogButtonBox { id: control implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, - (control.count === 1 ? contentWidth * 2 : contentWidth) + leftPadding + rightPadding) + (control.count === 1 ? implicitContentWidth * 2 : implicitContentWidth) + leftPadding + rightPadding) implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, - contentHeight + topPadding + bottomPadding) + implicitContentHeight + topPadding + bottomPadding) + contentWidth: contentItem.contentWidth spacing: 1 padding: 12 diff --git a/src/imports/controls/universal/DialogButtonBox.qml b/src/imports/controls/universal/DialogButtonBox.qml index ac2dc541..0458c39d 100644 --- a/src/imports/controls/universal/DialogButtonBox.qml +++ b/src/imports/controls/universal/DialogButtonBox.qml @@ -43,9 +43,10 @@ T.DialogButtonBox { id: control implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, - (control.count === 1 ? contentWidth * 2 : contentWidth) + leftPadding + rightPadding) + (control.count === 1 ? implicitContentWidth * 2 : implicitContentWidth) + leftPadding + rightPadding) implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, - contentHeight + topPadding + bottomPadding) + implicitContentHeight + topPadding + bottomPadding) + contentWidth: contentItem.contentWidth spacing: 4 padding: 24 -- cgit v1.2.3