aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquicktabbar_p.h
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-01-05 14:49:49 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-01-10 14:09:35 +0000
commit24acfcafdf66f9ade03d0f98520a5d6c02bb2a1c (patch)
tree10b13f4b833d2c56988b279ad71c5419000c7e8f /src/quicktemplates2/qquicktabbar_p.h
parent463e46245543540652168861b3d6c65980fb7b05 (diff)
QQuickTabBar: fix implicit size calculation
Before, the implicit size of TabBar was calculated based on the content size of the ListView that TabBar uses internally. The problem was that ListView calculates the content size based on the explicit size of the items. There was a circular dependency, because TabBar resized the tabs to the size of the view. To avoid the circular dependency, TabBar now calculates the content size based on the total implicit size of the tabs. As before, explicit size is respected for tabs that have it set. [ChangeLog][Controls][TabBar] Added contentWidth and contentHeight properties that are automatically calculated based on the total size of the tab items, but can be manually overridden if desired. This fixes an issue that TabBar was not able to reliably calculate an implicit size, and could in certain scenarios enter an infinite loop due to a circular dependency between the items' sizes and the tabbar's size. Task-number: QTBUG-57858 Change-Id: Ie303cbc54247e87b0affc6bf32c7bf99acea4571 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquicktabbar_p.h')
-rw-r--r--src/quicktemplates2/qquicktabbar_p.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquicktabbar_p.h b/src/quicktemplates2/qquicktabbar_p.h
index 7e590009..2fec756b 100644
--- a/src/quicktemplates2/qquicktabbar_p.h
+++ b/src/quicktemplates2/qquicktabbar_p.h
@@ -58,6 +58,8 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTabBar : public QQuickContainer
{
Q_OBJECT
Q_PROPERTY(Position position READ position WRITE setPosition NOTIFY positionChanged FINAL)
+ Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth RESET resetContentWidth NOTIFY contentWidthChanged FINAL REVISION 2)
+ Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight RESET resetContentHeight NOTIFY contentHeightChanged FINAL REVISION 2)
public:
explicit QQuickTabBar(QQuickItem *parent = nullptr);
@@ -71,8 +73,18 @@ public:
Position position() const;
void setPosition(Position position);
+ qreal contentWidth() const;
+ void setContentWidth(qreal width);
+ void resetContentWidth();
+
+ qreal contentHeight() const;
+ void setContentHeight(qreal height);
+ void resetContentHeight();
+
Q_SIGNALS:
void positionChanged();
+ void contentWidthChanged();
+ void contentHeightChanged();
protected:
void updatePolish() override;