diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-08-09 09:15:08 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2018-08-09 16:20:56 +0000 |
commit | 1d6dcee6cc75b65092715acc59d4481a2dfeb5ec (patch) | |
tree | 85702162a38b943ef390555a73e63d4e5ebf7e0c /src/quick/items/qquicktableview_p.h | |
parent | 82da798499aa8b656e771191332864a703069739 (diff) |
QQuickTableView: override contentWidth/Height properties
TableView uses contentWidth/height to report the size of the table
(this will e.g make scrollbars written for Flickable work out of the
box). This value is continuously calculated, and will change/improve
as more columns are loaded into view. At the same time, we want to
open up for the possibility that the application can set the content
width explicitly, in case it knows what the exact width should be from
the start. We therefore override the contentWidth/height properties from
QQuickFlickable, to be able to implement this combined behavior. This
also lets us lazy build the table if the application needs to know the
content size early on. The latter will also fix problems related to
querying the content size from Component.onCompleted.
Change-Id: Ife7ef551dc46cf15d6940e3c6dff78545a3e4330
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quick/items/qquicktableview_p.h')
-rw-r--r-- | src/quick/items/qquicktableview_p.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/quick/items/qquicktableview_p.h b/src/quick/items/qquicktableview_p.h index fa7561554e..513e644e43 100644 --- a/src/quick/items/qquicktableview_p.h +++ b/src/quick/items/qquicktableview_p.h @@ -79,6 +79,8 @@ class Q_QUICK_PRIVATE_EXPORT QQuickTableView : public QQuickFlickable Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) Q_PROPERTY(bool reuseItems READ reuseItems WRITE setReuseItems NOTIFY reuseItemsChanged) + Q_PROPERTY(qreal contentWidth READ explicitContentWidth WRITE setExplicitContentWidth NOTIFY contentWidthOverrideChanged) + Q_PROPERTY(qreal contentHeight READ explicitContentHeight WRITE setExplicitContentWidth NOTIFY contentHeightOverrideChanged) public: QQuickTableView(QQuickItem *parent = nullptr); @@ -122,6 +124,11 @@ public: bool reuseItems() const; void setReuseItems(bool reuseItems); + qreal explicitContentWidth() const; + void setExplicitContentWidth(qreal width); + qreal explicitContentHeight() const; + void setExplicitContentHeight(qreal height); + static QQuickTableViewAttached *qmlAttachedProperties(QObject *); Q_SIGNALS: @@ -139,6 +146,8 @@ Q_SIGNALS: void modelChanged(); void delegateChanged(); void reuseItemsChanged(); + void contentWidthOverrideChanged(); + void contentHeightOverrideChanged(); protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; |