summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-04-16 16:11:14 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-05-05 16:57:39 +0000
commitc021a6017600888165ab1807836a0965c9e82af5 (patch)
tree5c779802d245f1bc2ad190329d37a39573e61aac
parent55a5e846388ac2b37953fee7a642a9e53b457d45 (diff)
downloadqttools-c021a6017600888165ab1807836a0965c9e82af5.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. Fixes: QTBUG-49591 Change-Id: Ic00f5bb8a2a1fe3d77358dc20c441bf763bb9204 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io> (cherry picked from commit 908660847ccd632fbb18f605d387ce806ab1be1e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-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 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,