diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-04-16 16:11:14 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-05-05 17:15:32 +0200 |
commit | 908660847ccd632fbb18f605d387ce806ab1be1e (patch) | |
tree | 79bfcfba05d98035706f4c9e0f542e22e4044bf5 /src | |
parent | 3265986604e7333e91f7e03e8fb3efcca98a9e32 (diff) | |
download | qttools-908660847ccd632fbb18f605d387ce806ab1be1e.tar.gz |
Qt Designer: Fix saving of item view header visibility on page based containers
Use Qt::WA_WState_Hidden for header visibility when the item
view is hidden.
Pick-to: 6.1 5.15
Fixes: QTBUG-49591
Change-Id: Ic00f5bb8a2a1fe3d77358dc20c441bf763bb9204
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/designer/src/lib/shared/qdesigner_propertysheet.cpp | 19 | ||||
-rw-r--r-- | src/designer/src/lib/shared/qdesigner_propertysheet_p.h | 1 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp index eeaf48fdf..209582b1e 100644 --- a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp +++ b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp @@ -51,6 +51,7 @@ #include <QtWidgets/qtoolbar.h> #include <QtWidgets/qmainwindow.h> #include <QtWidgets/qmenubar.h> +#include <QtWidgets/qheaderview.h> #include <QtGui/qaction.h> @@ -562,6 +563,7 @@ QDesignerPropertySheet::PropertyType QDesignerPropertySheet::propertyTypeFromNam propertyTypeHash.insert(QStringLiteral("checkable"), PropertyCheckable); propertyTypeHash.insert(QStringLiteral("accessibleName"), PropertyAccessibility); propertyTypeHash.insert(QStringLiteral("accessibleDescription"), PropertyAccessibility); + propertyTypeHash.insert(QStringLiteral("visible"), PropertyVisible); propertyTypeHash.insert(QStringLiteral("windowTitle"), PropertyWindowTitle); propertyTypeHash.insert(QStringLiteral("windowIcon"), PropertyWindowIcon); propertyTypeHash.insert(QStringLiteral("windowFilePath"), PropertyWindowFilePath); @@ -1085,7 +1087,22 @@ QVariant QDesignerPropertySheet::property(int index) const return QVariant::fromValue(value); } - return metaProperty(index); + QVariant result = metaProperty(index); + // QTBUG-49591: "visible" is only exposed for QHeaderView as a fake + // property ("headerVisible") for the item view. If the item view is not + // visible (on a page based container), check the WA_WState_Hidden instead, + // since otherwise false is returned when saving. + if (result.typeId() == QMetaType::Bool && !result.toBool() + && d->m_object->isWidgetType() + && propertyType(index) == PropertyVisible) { + if (auto *hv = qobject_cast<QHeaderView *>(d->m_object)) { + if (auto *parent = hv->parentWidget()) { + if (!parent->isVisible()) + result = QVariant(!hv->testAttribute(Qt::WA_WState_Hidden)); + } + } + } + return result; } QVariant QDesignerPropertySheet::metaProperty(int index) const diff --git a/src/designer/src/lib/shared/qdesigner_propertysheet_p.h b/src/designer/src/lib/shared/qdesigner_propertysheet_p.h index 49380e1ee..e066d0c4f 100644 --- a/src/designer/src/lib/shared/qdesigner_propertysheet_p.h +++ b/src/designer/src/lib/shared/qdesigner_propertysheet_p.h @@ -157,6 +157,7 @@ public: PropertyGeometry, PropertyChecked, PropertyCheckable, + PropertyVisible, PropertyWindowTitle, PropertyWindowIcon, PropertyWindowFilePath, |