diff options
author | Nicolas Ettlin <nicolas.ettlin@me.com> | 2018-07-13 15:48:57 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-07-18 18:22:23 +0000 |
commit | ab1df24c8283cafd76f05c86004963c4c2d0673f (patch) | |
tree | 17c7764e393ca21f66293addcc831e745bc56d20 /src/quick/items | |
parent | 790e2f37d451933c4fe24c64e655e65e9e9c0a05 (diff) |
Qt Quick Table View: set the default row and column spacing to 0
Currently, in the TableView QML component, the initial row and column
spacing is set to (-1, -1), as in the default QSizeF constructor. As
the negative spacing was ignored when positioning the items, but taken
in account when computing the total content size, it caused an issue
where the user wouldn’t be able to scroll to the bottom right corner of
the TableView. This commit fixes this issue by setting a default
spacing to (0, 0). It also prevents the developer from using invalid
spacing values (such as negative numbers, NaN or Infinite).
Task-number: QTBUG-69454
Change-Id: I343475790c384954372afad0a778f8da7dff0b0d
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quick/items')
-rw-r--r-- | src/quick/items/qquicktableview.cpp | 4 | ||||
-rw-r--r-- | src/quick/items/qquicktableview_p_p.h | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 149c01a692..b5668ccf53 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -1227,6 +1227,8 @@ qreal QQuickTableView::rowSpacing() const void QQuickTableView::setRowSpacing(qreal spacing) { Q_D(QQuickTableView); + if (qt_is_nan(spacing) || !qt_is_finite(spacing) || spacing < 0) + return; if (qFuzzyCompare(d->cellSpacing.height(), spacing)) return; @@ -1243,6 +1245,8 @@ qreal QQuickTableView::columnSpacing() const void QQuickTableView::setColumnSpacing(qreal spacing) { Q_D(QQuickTableView); + if (qt_is_nan(spacing) || !qt_is_finite(spacing) || spacing < 0) + return; if (qFuzzyCompare(d->cellSpacing.width(), spacing)) return; diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h index cdea202024..f0e743877b 100644 --- a/src/quick/items/qquicktableview_p_p.h +++ b/src/quick/items/qquicktableview_p_p.h @@ -197,7 +197,7 @@ public: TableEdgeLoadRequest loadRequest; QPoint contentSizeBenchMarkPoint = QPoint(-1, -1); - QSizeF cellSpacing; + QSizeF cellSpacing = QSizeF(0, 0); QMarginsF tableMargins; int cacheBuffer = kDefaultCacheBuffer; |