summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-04-16 16:11:14 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-05-05 20:12:35 +0200
commit3b3516b60998e1e7f551422fe4ec11ed2e7c2a2a (patch)
tree983ef29680ea59d593d3f352739838a3f775fe3a
parenta824bca18ec356d322e551b8a01b7b0e051ba1aa (diff)
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. Fixes: QTBUG-49591 Change-Id: Ic00f5bb8a2a1fe3d77358dc20c441bf763bb9204 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> (cherry picked from commit 908660847ccd632fbb18f605d387ce806ab1be1e)
-rw-r--r--src/designer/src/lib/shared/qdesigner_propertysheet.cpp19
-rw-r--r--src/designer/src/lib/shared/qdesigner_propertysheet_p.h1
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 963b4d2a0..071fc6e7d 100644
--- a/src/designer/src/lib/shared/qdesigner_propertysheet.cpp
+++ b/src/designer/src/lib/shared/qdesigner_propertysheet.cpp
@@ -54,6 +54,7 @@
#include <QtWidgets/qtoolbar.h>
#include <QtWidgets/qmainwindow.h>
#include <QtWidgets/qmenubar.h>
+#include <QtWidgets/qheaderview.h>
QT_BEGIN_NAMESPACE
@@ -561,6 +562,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);
@@ -1066,7 +1068,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.type() == QVariant::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 746214102..50266c839 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,