summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2017-09-01 15:00:00 +0200
committerAndy Shaw <andy.shaw@qt.io>2017-09-04 19:02:18 +0000
commit03855e3dc7f22df38c9e20572beb0828441c204c (patch)
tree9d02bd6a0d5bfae7b465328b3624ffa0eb7e9b60
parent5c50201d616eeefe61b960a8b21d3adbae8c26a0 (diff)
downloadqttools-03855e3dc7f22df38c9e20572beb0828441c204c.tar.gz
Account for custom property sheet extensions when getting objectName
In order to account for custom property sheet extensions in a custom widget plugin, it needs to be possible to obtain the objectName value from a QVariant containing a QString. So to enable this, a check is done to see if the variant is storing a PropertySheetStringValue. If it is not then it is expected to be convertable to a string. Task-number: QTBUG-62936 Change-Id: I8ce2053256a5b18851254c3ed1d6037d12023bf5 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--src/designer/src/lib/shared/qdesigner_taskmenu.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/designer/src/lib/shared/qdesigner_taskmenu.cpp b/src/designer/src/lib/shared/qdesigner_taskmenu.cpp
index 946673553..601fb657b 100644
--- a/src/designer/src/lib/shared/qdesigner_taskmenu.cpp
+++ b/src/designer/src/lib/shared/qdesigner_taskmenu.cpp
@@ -88,9 +88,10 @@ static QString objName(const QDesignerFormEditorInterface *core, QObject *object
const QString objectNameProperty = QStringLiteral("objectName");
const int index = sheet->indexOf(objectNameProperty);
- const qdesigner_internal::PropertySheetStringValue objectNameValue
- = qvariant_cast<qdesigner_internal::PropertySheetStringValue>(sheet->property(index));
- return objectNameValue.value();
+ const QVariant v = sheet->property(index);
+ if (v.canConvert<qdesigner_internal::PropertySheetStringValue>())
+ return v.value<qdesigner_internal::PropertySheetStringValue>().value();
+ return v.toString();
}
enum { ApplyMinimumWidth = 0x1, ApplyMinimumHeight = 0x2, ApplyMaximumWidth = 0x4, ApplyMaximumHeight = 0x8 };