diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2020-05-05 16:08:42 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-05-20 09:00:41 +0200 |
commit | 2c9dae7b22f9dc857715ca7da64185eed9523eb4 (patch) | |
tree | dc1fb643bd20c5b98a12ac76167bb9fd45637667 | |
parent | 5592ccf7884b272b4b17354101bd20ba9012638a (diff) |
TableView: allow negative spacing
There is no apparent reason why negative spacing should not be allowed.
And in fact, you can use negative spacing to eliminate double edges
in the grid when the delegate is e.g a rectangle with a border.
Fixes: QTBUG-83956
Change-Id: I3be9d58ac8c43142e26e75165274e41872e878f4
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
(cherry picked from commit adfff7ec77223dfdd8c29327dc0f0181972516ef)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/quick/items/qquicktableview.cpp | 4 | ||||
-rw-r--r-- | tests/auto/quick/qquicktableview/tst_qquicktableview.cpp | 15 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index c7882fb2b1..de42d42445 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -2640,7 +2640,7 @@ qreal QQuickTableView::rowSpacing() const void QQuickTableView::setRowSpacing(qreal spacing) { Q_D(QQuickTableView); - if (qt_is_nan(spacing) || !qt_is_finite(spacing) || spacing < 0) + if (qt_is_nan(spacing) || !qt_is_finite(spacing)) return; if (qFuzzyCompare(d->cellSpacing.height(), spacing)) return; @@ -2658,7 +2658,7 @@ qreal QQuickTableView::columnSpacing() const void QQuickTableView::setColumnSpacing(qreal spacing) { Q_D(QQuickTableView); - if (qt_is_nan(spacing) || !qt_is_finite(spacing) || spacing < 0) + if (qt_is_nan(spacing) || !qt_is_finite(spacing)) return; if (qFuzzyCompare(d->cellSpacing.width(), spacing)) return; diff --git a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp index ef39a91a65..b876ead301 100644 --- a/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp +++ b/tests/auto/quick/qquicktableview/tst_qquicktableview.cpp @@ -1316,15 +1316,22 @@ void tst_QQuickTableView::checkSpacingValues() QCOMPARE(tableView->contentWidth(), expectedInitialContentWidth); QCOMPARE(tableView->contentHeight(), expectedInitialContentHeight); - // Invalid assignments (should ignore) + // Negative spacing is allowed, and can be used to eliminate double edges + // in the grid if the delegate is a rectangle with a border. tableView->setRowSpacing(-1); - tableView->setColumnSpacing(-5); + tableView->setColumnSpacing(-1); + QCOMPARE(tableView->rowSpacing(), -1); + QCOMPARE(tableView->columnSpacing(), -1); + + tableView->setRowSpacing(10); + tableView->setColumnSpacing(10); + // Invalid assignments (should ignore) tableView->setRowSpacing(INFINITY); tableView->setColumnSpacing(INFINITY); tableView->setRowSpacing(NAN); tableView->setColumnSpacing(NAN); - QCOMPARE(tableView->rowSpacing(), 42); - QCOMPARE(tableView->columnSpacing(), 12); + QCOMPARE(tableView->rowSpacing(), 10); + QCOMPARE(tableView->columnSpacing(), 10); } void tst_QQuickTableView::checkDelegateParent() |