diff options
29 files changed, 320 insertions, 44 deletions
diff --git a/src/imports/calendar/doc/src/qtlabscalendar-qmltypes.qdoc b/src/imports/calendar/doc/src/qtlabscalendar-qmltypes.qdoc index 81abf52a..b63263a9 100644 --- a/src/imports/calendar/doc/src/qtlabscalendar-qmltypes.qdoc +++ b/src/imports/calendar/doc/src/qtlabscalendar-qmltypes.qdoc @@ -38,9 +38,9 @@ The QML types can be imported into your application using the following import statement in your .qml file: - \badcode + \qml import Qt.labs.calendar 1.0 - \endcode + \endqml \section1 QML Types diff --git a/src/imports/controls/HorizontalHeaderView.qml b/src/imports/controls/HorizontalHeaderView.qml index 7f0454da..ec91af25 100644 --- a/src/imports/controls/HorizontalHeaderView.qml +++ b/src/imports/controls/HorizontalHeaderView.qml @@ -55,7 +55,9 @@ T.HorizontalHeaderView { Text { id: text - text: model[control.textRole] + text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] + : model[control.textRole]) + : modelData width: parent.width height: parent.height horizontalAlignment: Text.AlignHCenter diff --git a/src/imports/controls/Menu.qml b/src/imports/controls/Menu.qml index 041942f5..cf3a52f2 100644 --- a/src/imports/controls/Menu.qml +++ b/src/imports/controls/Menu.qml @@ -56,7 +56,9 @@ T.Menu { contentItem: ListView { implicitHeight: contentHeight model: control.contentModel - interactive: Window.window ? contentHeight > Window.window.height : false + interactive: Window.window + ? contentHeight + control.topPadding + control.bottomPadding > Window.window.height + : false clip: true currentIndex: control.currentIndex diff --git a/src/imports/controls/VerticalHeaderView.qml b/src/imports/controls/VerticalHeaderView.qml index 5fbfaedf..3fc9ca5a 100644 --- a/src/imports/controls/VerticalHeaderView.qml +++ b/src/imports/controls/VerticalHeaderView.qml @@ -55,7 +55,9 @@ T.VerticalHeaderView { Text { id: text - text: model[control.textRole] + text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] + : model[control.textRole]) + : modelData width: parent.width height: parent.height horizontalAlignment: Text.AlignHCenter diff --git a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc index 395f3b36..ac306aaa 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-index.qdoc @@ -46,9 +46,9 @@ The \l{Qt Quick Controls QML Types}{QML types} can be imported into your application using the following import statement in your \c {.qml} file: - \code \QtMinorVersion + \qml \QtMinorVersion import QtQuick.Controls 2.\1 - \endcode + \endqml The \l{Qt Quick Controls C++ Classes}{C++ classes} can be included into your application using the following include statement: diff --git a/src/imports/controls/doc/src/qtquickcontrols2-qmltypes.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-qmltypes.qdoc index 360d2059..7fbc8c4d 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-qmltypes.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-qmltypes.qdoc @@ -40,9 +40,9 @@ Qt Quick Controls QML types can be imported into your application using the following import statement in your .qml file: - \badcode \QtMinorVersion + \qml \QtMinorVersion import QtQuick.Controls 2.\1 - \endcode + \endqml \section1 QML Types \generatelist {qmltypesbymodule QtQuick.Controls} diff --git a/src/imports/controls/fusion/HorizontalHeaderView.qml b/src/imports/controls/fusion/HorizontalHeaderView.qml index 3d0f247b..bbd9dc3f 100644 --- a/src/imports/controls/fusion/HorizontalHeaderView.qml +++ b/src/imports/controls/fusion/HorizontalHeaderView.qml @@ -65,7 +65,9 @@ T.HorizontalHeaderView { Text { id: text - text: model[control.textRole] + text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] + : model[control.textRole]) + : modelData width: parent.width height: parent.height horizontalAlignment: Text.AlignHCenter diff --git a/src/imports/controls/fusion/Menu.qml b/src/imports/controls/fusion/Menu.qml index e06b70fd..8bace6b9 100644 --- a/src/imports/controls/fusion/Menu.qml +++ b/src/imports/controls/fusion/Menu.qml @@ -59,7 +59,9 @@ T.Menu { contentItem: ListView { implicitHeight: contentHeight model: control.contentModel - interactive: Window.window ? contentHeight > Window.window.height : false + interactive: Window.window + ? contentHeight + control.topPadding + control.bottomPadding > Window.window.height + : false clip: true currentIndex: control.currentIndex diff --git a/src/imports/controls/fusion/VerticalHeaderView.qml b/src/imports/controls/fusion/VerticalHeaderView.qml index 5ad0db8f..b220cdf2 100644 --- a/src/imports/controls/fusion/VerticalHeaderView.qml +++ b/src/imports/controls/fusion/VerticalHeaderView.qml @@ -65,7 +65,9 @@ T.VerticalHeaderView { Text { id: text - text: model[control.textRole] + text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] + : model[control.textRole]) + : modelData width: parent.width height: parent.height horizontalAlignment: Text.AlignHCenter diff --git a/src/imports/controls/imagine/HorizontalHeaderView.qml b/src/imports/controls/imagine/HorizontalHeaderView.qml index 7f0454da..ec91af25 100644 --- a/src/imports/controls/imagine/HorizontalHeaderView.qml +++ b/src/imports/controls/imagine/HorizontalHeaderView.qml @@ -55,7 +55,9 @@ T.HorizontalHeaderView { Text { id: text - text: model[control.textRole] + text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] + : model[control.textRole]) + : modelData width: parent.width height: parent.height horizontalAlignment: Text.AlignHCenter diff --git a/src/imports/controls/imagine/Menu.qml b/src/imports/controls/imagine/Menu.qml index 20a34467..832565e6 100644 --- a/src/imports/controls/imagine/Menu.qml +++ b/src/imports/controls/imagine/Menu.qml @@ -69,7 +69,9 @@ T.Menu { contentItem: ListView { implicitHeight: contentHeight model: control.contentModel - interactive: Window.window ? contentHeight > Window.window.height : false + interactive: Window.window + ? contentHeight + control.topPadding + control.bottomPadding > Window.window.height + : false clip: true currentIndex: control.currentIndex diff --git a/src/imports/controls/imagine/VerticalHeaderView.qml b/src/imports/controls/imagine/VerticalHeaderView.qml index 5fbfaedf..3fc9ca5a 100644 --- a/src/imports/controls/imagine/VerticalHeaderView.qml +++ b/src/imports/controls/imagine/VerticalHeaderView.qml @@ -55,7 +55,9 @@ T.VerticalHeaderView { Text { id: text - text: model[control.textRole] + text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] + : model[control.textRole]) + : modelData width: parent.width height: parent.height horizontalAlignment: Text.AlignHCenter diff --git a/src/imports/controls/material/HorizontalHeaderView.qml b/src/imports/controls/material/HorizontalHeaderView.qml index 504579cc..fd672f34 100644 --- a/src/imports/controls/material/HorizontalHeaderView.qml +++ b/src/imports/controls/material/HorizontalHeaderView.qml @@ -56,7 +56,9 @@ T.HorizontalHeaderView { Text { id: text - text: model[control.textRole] + text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] + : model[control.textRole]) + : modelData width: parent.width height: parent.height horizontalAlignment: Text.AlignHCenter diff --git a/src/imports/controls/material/Menu.qml b/src/imports/controls/material/Menu.qml index d28713a7..94bcc15e 100644 --- a/src/imports/controls/material/Menu.qml +++ b/src/imports/controls/material/Menu.qml @@ -74,7 +74,9 @@ T.Menu { implicitHeight: contentHeight model: control.contentModel - interactive: Window.window ? contentHeight > Window.window.height : false + interactive: Window.window + ? contentHeight + control.topPadding + control.bottomPadding > Window.window.height + : false clip: true currentIndex: control.currentIndex diff --git a/src/imports/controls/material/VerticalHeaderView.qml b/src/imports/controls/material/VerticalHeaderView.qml index 7f8ecc92..5fc5aebe 100644 --- a/src/imports/controls/material/VerticalHeaderView.qml +++ b/src/imports/controls/material/VerticalHeaderView.qml @@ -56,7 +56,9 @@ T.VerticalHeaderView { Text { id: text - text: model[control.textRole] + text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] + : model[control.textRole]) + : modelData width: parent.width height: parent.height horizontalAlignment: Text.AlignHCenter diff --git a/src/imports/controls/universal/HorizontalHeaderView.qml b/src/imports/controls/universal/HorizontalHeaderView.qml index 8cdfda35..47daa8ce 100644 --- a/src/imports/controls/universal/HorizontalHeaderView.qml +++ b/src/imports/controls/universal/HorizontalHeaderView.qml @@ -57,7 +57,9 @@ T.HorizontalHeaderView { Text { id: text - text: model[control.textRole] + text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] + : model[control.textRole]) + : modelData width: parent.width height: parent.height horizontalAlignment: Text.AlignHCenter diff --git a/src/imports/controls/universal/Menu.qml b/src/imports/controls/universal/Menu.qml index 619cfa40..4814d006 100644 --- a/src/imports/controls/universal/Menu.qml +++ b/src/imports/controls/universal/Menu.qml @@ -56,7 +56,9 @@ T.Menu { contentItem: ListView { implicitHeight: contentHeight model: control.contentModel - interactive: Window.window ? contentHeight > Window.window.height : false + interactive: Window.window + ? contentHeight + control.topPadding + control.bottomPadding > Window.window.height + : false clip: true currentIndex: control.currentIndex diff --git a/src/imports/controls/universal/VerticalHeaderView.qml b/src/imports/controls/universal/VerticalHeaderView.qml index 7c7544af..04408d68 100644 --- a/src/imports/controls/universal/VerticalHeaderView.qml +++ b/src/imports/controls/universal/VerticalHeaderView.qml @@ -57,7 +57,9 @@ T.VerticalHeaderView { Text { id: text - text: model[control.textRole] + text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole] + : model[control.textRole]) + : modelData width: parent.width height: parent.height horizontalAlignment: Text.AlignHCenter diff --git a/src/imports/platform/doc/src/qtlabsplatform-qmltypes.qdoc b/src/imports/platform/doc/src/qtlabsplatform-qmltypes.qdoc index dec67b72..f1a4daf3 100644 --- a/src/imports/platform/doc/src/qtlabsplatform-qmltypes.qdoc +++ b/src/imports/platform/doc/src/qtlabsplatform-qmltypes.qdoc @@ -38,9 +38,9 @@ The QML types can be imported into your application using the following import statement in your .qml file: - \badcode + \qml import Qt.labs.platform 1.1 - \endcode + \endqml \section1 QML Types diff --git a/src/imports/templates/doc/src/qtquicktemplates2-qmltypes.qdoc b/src/imports/templates/doc/src/qtquicktemplates2-qmltypes.qdoc index f93d6a37..fb7809e4 100644 --- a/src/imports/templates/doc/src/qtquicktemplates2-qmltypes.qdoc +++ b/src/imports/templates/doc/src/qtquicktemplates2-qmltypes.qdoc @@ -37,9 +37,9 @@ The QML types can be imported using the following import statement in your \c .qml file: - \badcode - import QtQuick.Templates 2.12 as T - \endcode + \qml \QtMinorVersion + import QtQuick.Templates 2.\1 as T + \endqml For the sake of clarity, there is a one-to-one mapping between the types provided by the \c QtQuick.Templates and \c QtQuick.Controls imports. For diff --git a/src/quicktemplates2/qquickheaderview.cpp b/src/quicktemplates2/qquickheaderview.cpp index 49463944..5c465cc7 100644 --- a/src/quicktemplates2/qquickheaderview.cpp +++ b/src/quicktemplates2/qquickheaderview.cpp @@ -151,7 +151,11 @@ This property holds the model role used to display text in each header cell. - The default value is the \c "display" role. + When the model has multiple roles, textRole can be set to determine which + role should be displayed. + + If model is a QAbstractItemModel then it will default to "display"; otherwise + it is empty. \sa QAbstractItemModel::roleNames() */ @@ -161,7 +165,11 @@ This property holds the model role used to display text in each header cell. - The default value is the \c "display" role. + When the model has multiple roles, textRole can be set to determine which + role should be displayed. + + If model is a QAbstractItemModel then it will default to "display"; otherwise + it is empty. \sa QAbstractItemModel::roleNames() */ @@ -241,6 +249,18 @@ void QQuickHeaderViewBasePrivate::syncModel() } QQuickTableViewPrivate::syncModel(); + + isTransposed = false; + const auto aim = model->abstractItemModel(); + if (orientation() == Qt::Horizontal) { + // For models that are just a list or a number, and especially not a + // table, we transpose the view when the orientation is horizontal. + // The model (list) will then be laid out horizontally rather than + // vertically, which is the otherwise the default. + isTransposed = !aim || aim->columnCount() == 1; + } + if (m_textRole.isEmpty() && aim) + m_textRole = QLatin1String("display"); } void QQuickHeaderViewBasePrivate::syncSyncView() diff --git a/src/quicktemplates2/qquickheaderview_p_p.h b/src/quicktemplates2/qquickheaderview_p_p.h index 961c554b..655c2a58 100644 --- a/src/quicktemplates2/qquickheaderview_p_p.h +++ b/src/quicktemplates2/qquickheaderview_p_p.h @@ -112,7 +112,7 @@ protected: }; QStack<SectionSize> m_hiddenSectionSizes; bool m_modelExplicitlySetByUser = false; - QString m_textRole = QStringLiteral("display"); + QString m_textRole; }; class QQuickHorizontalHeaderViewPrivate : public QQuickHeaderViewBasePrivate diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp index 08982f4c..664fc265 100644 --- a/src/quicktemplates2/qquickpopup.cpp +++ b/src/quicktemplates2/qquickpopup.cpp @@ -471,6 +471,7 @@ void QQuickPopupPrivate::finalizeEnterTransition() if (focus) popupItem->setFocus(true); transitionState = NoTransition; + getPositioner()->reposition(); emit q->openedChanged(); emit q->opened(); } diff --git a/src/quicktemplates2/qquickpopuppositioner.cpp b/src/quicktemplates2/qquickpopuppositioner.cpp index ebd8ff29..dbe8ac1d 100644 --- a/src/quicktemplates2/qquickpopuppositioner.cpp +++ b/src/quicktemplates2/qquickpopuppositioner.cpp @@ -108,10 +108,11 @@ void QQuickPopupPositioner::reposition() return; } - const qreal w = popupItem->width(); - const qreal h = popupItem->height(); - const qreal iw = popupItem->implicitWidth(); - const qreal ih = popupItem->implicitHeight(); + const qreal scale = popupItem->scale(); + const qreal w = popupItem->width() * scale; + const qreal h = popupItem->height() * scale; + const qreal iw = popupItem->implicitWidth() * scale; + const qreal ih = popupItem->implicitHeight() * scale; bool widthAdjusted = false; bool heightAdjusted = false; @@ -257,10 +258,9 @@ void QQuickPopupPositioner::reposition() } if (!p->hasWidth && widthAdjusted && rect.width() > 0) - popupItem->setWidth(rect.width()); + popupItem->setWidth(rect.width() / scale); if (!p->hasHeight && heightAdjusted && rect.height() > 0) - popupItem->setHeight(rect.height()); - + popupItem->setHeight(rect.height() / scale); m_positioning = false; } diff --git a/tests/auto/controls/data/tst_popup.qml b/tests/auto/controls/data/tst_popup.qml index 27043d1c..71d6f2d7 100644 --- a/tests/auto/controls/data/tst_popup.qml +++ b/tests/auto/controls/data/tst_popup.qml @@ -326,6 +326,7 @@ TestCase { var control = createTemporaryObject(popupControl, testCase, {visible: true, margins: 0}) verify(control) + control.scale = 1.0 control.width = control.implicitWidth = testCase.width + 10 control.height = control.implicitHeight = testCase.height + 10 @@ -1293,8 +1294,8 @@ TestCase { // Center the popup in the window via the overlay. control.anchors.centerIn = Qt.binding(function() { return control.parent; }) compare(centerInSpy.count, 1) - compare(control.x, (overlay.width - control.width) / 2) - compare(control.y, (overlay.height - control.height) / 2) + compare(control.x, (overlay.width - (control.width * control.scale)) / 2) + compare(control.y, (overlay.height - (control.width * control.scale)) / 2) // Ensure that it warns when trying to set it to an item that's not its parent. var anotherItem = createTemporaryObject(rect, applicationWindow.contentItem, { x: 100, y: 100, width: 50, height: 50 }) @@ -1317,14 +1318,14 @@ TestCase { compare(control.parent, anotherItem) compare(control.anchors.centerIn, anotherItem) compare(centerInSpy.count, 4) - compare(control.x, (anotherItem.width - control.width) / 2) - compare(control.y, (anotherItem.height - control.height) / 2) + compare(control.x, (anotherItem.width - (control.width * control.scale)) / 2) + compare(control.y, (anotherItem.height - (control.height * control.scale)) / 2) // Check that anchors.centerIn beats x and y coordinates as it does in QQuickItem. control.x = 33; control.y = 44; - compare(control.x, (anotherItem.width - control.width) / 2) - compare(control.y, (anotherItem.height - control.height) / 2) + compare(control.x, (anotherItem.width - (control.width * control.scale)) / 2) + compare(control.y, (anotherItem.height - (control.height * control.scale)) / 2) // Check that the popup's x and y coordinates are restored when it's no longer centered. control.anchors.centerIn = undefined @@ -1335,8 +1336,8 @@ TestCase { // Test centering in the overlay while having a different parent (anotherItem). control.anchors.centerIn = overlay compare(centerInSpy.count, 6) - compare(control.x, (overlay.width - control.width) / 2) - compare(control.y, (overlay.height - control.height) / 2) + compare(control.x, (overlay.width - (control.width * control.scale)) / 2) + compare(control.y, (overlay.height - (control.height * control.scale)) / 2) // TODO: do this properly by creating a component or something applicationWindow.visible = false diff --git a/tests/auto/qquickheaderview/data/ListModel.qml b/tests/auto/qquickheaderview/data/ListModel.qml new file mode 100644 index 00000000..59021458 --- /dev/null +++ b/tests/auto/qquickheaderview/data/ListModel.qml @@ -0,0 +1,107 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.15 +import QtQuick.Window 2.15 +import QtQuick.Controls 2.15 +import TestTableModel 0.1 + +Window { + objectName: "window" + width: 400 + height: 400 + visible: true + + Component { + id: cellDelegate + Rectangle { + implicitHeight: 25 + implicitWidth: 50 + color: "red" + Text { + text: row + "," + column + } + } + } + + HorizontalHeaderView { + id: hhv + objectName: "horizontalHeader" + model: ["AAA", "BBB", "CCC", "DDD", "EEE"] + syncView: tv + anchors.top: parent.top + x: vhv.width + } + + VerticalHeaderView { + id: vhv + objectName: "verticalHeader" + model: ["111", "222", "333", "444", "555"] + syncView: tv + anchors.left: parent.left + y: hhv.height + } + + TableView { + id: tv + objectName: "tableView" + model: TestTableModel { + id: tm + objectName: "tableModel" + rowCount: 5 + columnCount: 5 + } + delegate: cellDelegate + anchors.top: hhv.bottom + anchors.left: vhv.right + anchors.right: parent.right + anchors.bottom: parent.bottom + } +} diff --git a/tests/auto/qquickheaderview/tst_qquickheaderview.cpp b/tests/auto/qquickheaderview/tst_qquickheaderview.cpp index 5ce5439d..611e39cb 100644 --- a/tests/auto/qquickheaderview/tst_qquickheaderview.cpp +++ b/tests/auto/qquickheaderview/tst_qquickheaderview.cpp @@ -42,6 +42,7 @@ #include <QAbstractItemModelTester> #include <QtQml/QQmlEngine> #include <QtQuick/private/qquickwindow_p.h> +#include <QtQuick/private/qquicktext_p.h> #include <QtQuickTemplates2/private/qquickapplicationwindow_p.h> #include <QtQuickTemplates2/private/qquickheaderview_p.h> #include <private/qquickheaderview_p_p.h> @@ -218,6 +219,7 @@ private slots: void testHeaderDataProxyModel(); void testOrientation(); void testModel(); + void listModel(); private: QQmlEngine *engine; @@ -349,6 +351,41 @@ void tst_QQuickHeaderView::testModel() QCOMPARE(modelChangedSpy.count(), 2); } +void tst_QQuickHeaderView::listModel() +{ + QQmlComponent component(engine); + component.loadUrl(testFileUrl("ListModel.qml")); + + QScopedPointer<QObject> root(component.create()); + QVERIFY2(root, qPrintable(component.errorString())); + + if (!QTest::qWaitForWindowActive(qobject_cast<QWindow *>(root.data()))) + QSKIP("Window failed to become active!"); + + auto hhv = root->findChild<QQuickHorizontalHeaderView *>("horizontalHeader"); + QVERIFY(hhv); + auto vhv = root->findChild<QQuickVerticalHeaderView *>("verticalHeader"); + QVERIFY(vhv); + + auto hhvCell1 = hhv->childAt(0, 0)->childAt(0, 0)->findChild<QQuickText *>(); + QVERIFY(hhvCell1); + QCOMPARE(hhvCell1->property("text"), "AAA"); + + auto hhvCell2 = hhv->childAt(hhvCell1->width() + 5, 0)-> + childAt(hhvCell1->width() + 5, 0)->findChild<QQuickText *>(); + QVERIFY(hhvCell2); + QCOMPARE(hhvCell2->property("text"), "BBB"); + + auto vhvCell1 = vhv->childAt(0, 0)->childAt(0, 0)->findChild<QQuickText *>(); + QVERIFY(vhvCell1); + QCOMPARE(vhvCell1->property("text"), "111"); + + auto vhvCell2 = vhv->childAt(0, vhvCell1->height() + 5)-> + childAt(0, vhvCell1->height() + 5)->findChild<QQuickText *>(); + QVERIFY(vhvCell2); + QCOMPARE(vhvCell2->property("text"), "222"); +} + QTEST_MAIN(tst_QQuickHeaderView) #include "tst_qquickheaderview.moc" diff --git a/tests/auto/qquickmenu/data/scrollableWithPadding.qml b/tests/auto/qquickmenu/data/scrollableWithPadding.qml new file mode 100644 index 00000000..86405ccb --- /dev/null +++ b/tests/auto/qquickmenu/data/scrollableWithPadding.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Window 2.11 + +Window { + title: "Test Window" + width: 300 + height: dummyItem.height * 10 + + property alias menu: menu + MenuItem { + id: dummyItem + objectName: "Dummy" + text: objectName + } + + Menu { + id: menu + topPadding: 10 + Repeater { + model: 10 + + delegate: MenuItem { + objectName: text + text: (index + 1) + } + } + } +} diff --git a/tests/auto/qquickmenu/tst_qquickmenu.cpp b/tests/auto/qquickmenu/tst_qquickmenu.cpp index 2fe47477..22aece0c 100644 --- a/tests/auto/qquickmenu/tst_qquickmenu.cpp +++ b/tests/auto/qquickmenu/tst_qquickmenu.cpp @@ -1588,6 +1588,7 @@ void tst_QQuickMenu::scrollable_data() QTest::addRow("Window") << QString::fromLatin1("windowScrollable.qml"); QTest::addRow("ApplicationWindow") << QString::fromLatin1("applicationWindowScrollable.qml"); + QTest::addRow("WithPadding") << QString::fromLatin1("scrollableWithPadding.qml"); } void tst_QQuickMenu::scrollable() |