Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
abstractpropertyeditor.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3// Qt-Security score:significant reason:default
4
6
8
9/*!
10 \class QDesignerPropertyEditorInterface
11
12 \brief The QDesignerPropertyEditorInterface class allows you to
13 query and manipulate the current state of Qt Widgets Designer's property
14 editor.
15
16 \inmodule QtDesigner
17
18 QDesignerPropertyEditorInterface contains a collection of
19 functions that is typically used to query the property editor for
20 its current state, and several slots manipulating it's state. The
21 interface also provide a signal, propertyChanged(), which is
22 emitted whenever a property changes in the property editor. The
23 signal's arguments are the property that changed and its new
24 value.
25
26 For example, when implementing a custom widget plugin, you can
27 connect the signal to a custom slot:
28
29 \snippet lib/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp 0
30
31 Then the custom slot can check if the new value is within the
32 range we want when a specified property, belonging to a particular
33 widget, changes:
34
35 \snippet lib/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp 1
36
37 The QDesignerPropertyEditorInterface class is not intended to be
38 instantiated directly. You can retrieve an interface to \QD's
39 property editor using the
40 QDesignerFormEditorInterface::propertyEditor() function. A pointer
41 to \QD's current QDesignerFormEditorInterface object (\c
42 formEditor in the examples above) is provided by the
43 QDesignerCustomWidgetInterface::initialize() function's
44 parameter. When implementing a custom widget plugin, you must
45 subclass the QDesignerCustomWidgetInterface to expose your plugin
46 to \QD.
47
48 The functions accessing the property editor are the core()
49 function that you can use to retrieve an interface to the form
50 editor, the currentPropertyName() function that returns the name
51 of the currently selected property in the property editor, the
52 object() function that returns the currently selected object in
53 \QD's workspace, and the isReadOnly() function that returns true
54 if the property editor is write proteced (otherwise false).
55
56 The slots manipulating the property editor's state are the
57 setObject() slot that you can use to change the currently selected
58 object in \QD's workspace, the setPropertyValue() slot that
59 changes the value of a given property and the setReadOnly() slot
60 that control the write protection of the property editor.
61
62 \sa QDesignerFormEditorInterface
63*/
64
65/*!
66 Constructs a property editor interface with the given \a parent and
67 the specified window \a flags.
68*/
69QDesignerPropertyEditorInterface::QDesignerPropertyEditorInterface(QWidget *parent, Qt::WindowFlags flags)
70 : QWidget(parent, flags)
71{
72}
73
74/*!
75 Destroys the property editor interface.
76*/
77QDesignerPropertyEditorInterface::~QDesignerPropertyEditorInterface() = default;
78
79/*!
80 Returns a pointer to \QD's current QDesignerFormEditorInterface
81 object.
82*/
83QDesignerFormEditorInterface *QDesignerPropertyEditorInterface::core() const
84{
85 return nullptr;
86}
87
88/*!
89 \fn bool QDesignerPropertyEditorInterface::isReadOnly() const
90
91 Returns true if the property editor is write protected; otherwise
92 false.
93
94 \sa setReadOnly()
95*/
96
97/*!
98 \fn QObject *QDesignerPropertyEditorInterface::object() const
99
100 Returns the currently selected object in \QD's workspace.
101
102 \sa setObject()
103*/
104
105/*!
106 \fn QString QDesignerPropertyEditorInterface::currentPropertyName() const
107
108 Returns the name of the currently selected property in the
109 property editor.
110
111 \sa setPropertyValue()
112*/
113
114/*!
115 \fn void QDesignerPropertyEditorInterface::propertyChanged(const QString &name, const QVariant &value)
116
117 This signal is emitted whenever a property changes in the property
118 editor. The property that changed and its new value are specified
119 by \a name and \a value respectively.
120
121 \sa setPropertyValue()
122*/
123
124/*!
125 \fn void QDesignerPropertyEditorInterface::setObject(QObject *object)
126
127 Changes the currently selected object in \QD's workspace, to \a
128 object.
129
130 \sa object()
131*/
132
133/*!
134 \fn void QDesignerPropertyEditorInterface::setPropertyValue(const QString &name, const QVariant &value, bool changed = true)
135
136 Sets the value of the property specified by \a name to \a
137 value.
138
139 In addition, the property is marked as \a changed in the property
140 editor, i.e. its value is different from the default value.
141
142 \sa currentPropertyName(), propertyChanged()
143*/
144
145/*!
146 \fn void QDesignerPropertyEditorInterface::setReadOnly(bool readOnly)
147
148 If \a readOnly is true, the property editor is made write
149 protected; otherwise the write protection is removed.
150
151 \sa isReadOnly()
152*/
153
154QT_END_NAMESPACE
Combined button and popup list for selecting options.