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
abstractformwindowcursor.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 QDesignerFormWindowCursorInterface
11
12 \brief The QDesignerFormWindowCursorInterface class allows you to
13 query and modify a form window's widget selection, and in addition
14 modify the properties of all the form's widgets.
15
16 \inmodule QtDesigner
17
18 QDesignerFormWindowCursorInterface is a convenience class that
19 provides an interface to the associated form window's text cursor;
20 it provides a collection of functions that enables you to query a
21 given form window's selection and change the selection's focus
22 according to defined modes (MoveMode) and movements
23 (MoveOperation). You can also use the interface to query the
24 form's widgets and change their properties.
25
26 The interface is not intended to be instantiated directly, but to
27 provide access to the selections and widgets of \QD's current form
28 windows. QDesignerFormWindowInterface always provides an
29 associated cursor interface. The form window for a given widget
30 can be retrieved using the static
31 QDesignerFormWindowInterface::findFormWindow() functions. For
32 example:
33
34 \snippet lib/tools_designer_src_lib_sdk_abstractformwindowcursor.cpp 0
35
36 You can retrieve any of \QD's current form windows through
37 \QD's \l {QDesignerFormWindowManagerInterface}{form window
38 manager}.
39
40 Once you have a form window's cursor interface, you can check if
41 the form window has a selection at all using the hasSelection()
42 function. You can query the form window for its total
43 widgetCount() and selectedWidgetCount(). You can retrieve the
44 currently selected widget (or widgets) using the current() or
45 selectedWidget() functions.
46
47 You can retrieve any of the form window's widgets using the
48 widget() function, and check if a widget is selected using the
49 isWidgetSelected() function. You can use the setProperty()
50 function to set the selected widget's properties, and the
51 setWidgetProperty() or resetWidgetProperty() functions to modify
52 the properties of any given widget.
53
54 Finally, you can change the selection by changing the text
55 cursor's position() using the setPosition() and movePosition()
56 functions.
57
58 \sa QDesignerFormWindowInterface, QDesignerFormWindowManagerInterface
59*/
60
61/*!
62 \enum QDesignerFormWindowCursorInterface::MoveOperation
63
64 This enum describes the types of text cursor operation that can occur in a form window.
65
66 \value NoMove The cursor does not move.
67 \value Start Moves the cursor to the start of the focus chain.
68 \value End Moves the cursor to the end of the focus chain.
69 \value Next Moves the cursor to the next widget in the focus chain.
70 \value Prev Moves the cursor to the previous widget in the focus chain.
71 \value Left The cursor moves to the left.
72 \value Right The cursor moves to the right.
73 \value Up The cursor moves upwards.
74 \value Down The cursor moves downwards.
75*/
76
77/*!
78 \enum QDesignerFormWindowCursorInterface::MoveMode
79
80 This enum describes the different modes that are used when the text cursor moves.
81
82 \value MoveAnchor The anchor moves with the cursor to its new location.
83 \value KeepAnchor The anchor remains at the cursor's old location.
84*/
85
86/*!
87 Returns true if the specified \a widget is selected; otherwise
88 returns false.
89*/
90bool QDesignerFormWindowCursorInterface::isWidgetSelected(QWidget *widget) const
91{
92 for (int index=0; index<selectedWidgetCount(); ++index) {
93 if (selectedWidget(index) == widget)
94 return true;
95 }
96
97 return false;
98}
99
100/*!
101 \fn virtual QDesignerFormWindowCursorInterface::~QDesignerFormWindowCursorInterface()
102
103 Destroys the cursor interface.
104*/
105
106/*!
107 \fn virtual QDesignerFormWindowInterface *QDesignerFormWindowCursorInterface::formWindow() const
108
109 Returns the form window interface associated with this cursor interface.
110*/
111
112/*!
113 \fn virtual bool QDesignerFormWindowCursorInterface::movePosition(MoveOperation operation, MoveMode mode)
114
115 Performs the given \a operation on the cursor using the specified
116 \a mode, and returns true if it completed successfully; otherwise
117 returns false.
118
119 \sa position(), setPosition()
120*/
121
122/*!
123 \fn virtual int QDesignerFormWindowCursorInterface::position() const
124
125 Returns the cursor position.
126
127 \sa setPosition(), movePosition()
128*/
129
130/*!
131 \fn virtual void QDesignerFormWindowCursorInterface::setPosition(int position, MoveMode mode = MoveAnchor)
132
133 Sets the position of the cursor to the given \a position using the
134 \a mode to specify how it is moved there.
135
136 \sa position(), movePosition()
137*/
138
139/*!
140 \fn virtual QWidget *QDesignerFormWindowCursorInterface::current() const
141
142 Returns the currently selected widget in the form window.
143
144 \sa selectedWidget()
145*/
146
147/*!
148 \fn virtual int QDesignerFormWindowCursorInterface::widgetCount() const
149
150 Returns the number of widgets in the form window.
151
152 \sa selectedWidgetCount()
153*/
154
155/*!
156 \fn virtual QWidget *QDesignerFormWindowCursorInterface::widget(int index) const
157
158 Returns the widget with the given \a index in the list of widgets
159 in the form window.
160
161 \sa selectedWidget()
162*/
163
164/*!
165 \fn virtual bool QDesignerFormWindowCursorInterface::hasSelection() const
166
167 Returns true if the form window contains a selection; otherwise
168 returns false.
169*/
170
171/*!
172 \fn virtual int QDesignerFormWindowCursorInterface::selectedWidgetCount() const
173
174 Returns the number of selected widgets in the form window.
175
176 \sa widgetCount()
177*/
178
179/*!
180 \fn virtual QWidget *QDesignerFormWindowCursorInterface::selectedWidget(int index) const
181
182 Returns the widget with the given \a index in the list of selected
183 widgets.
184
185 \sa current(), widget()
186*/
187
188/*!
189 \fn virtual void QDesignerFormWindowCursorInterface::setProperty(const QString &name, const QVariant &value)
190
191 Sets the property with the given \a name for the currently
192 selected widget to the specified \a value.
193
194 \sa setWidgetProperty(), resetWidgetProperty()
195*/
196
197/*!
198 \fn virtual void QDesignerFormWindowCursorInterface::setWidgetProperty(QWidget *widget, const QString &name, const QVariant &value)
199
200 Sets the property with the given \a name for the given \a widget
201 to the specified \a value.
202
203 \sa resetWidgetProperty(), setProperty()
204*/
205
206/*!
207 \fn virtual void QDesignerFormWindowCursorInterface::resetWidgetProperty(QWidget *widget, const QString &name)
208
209 Resets the property with the given \a name for the specified \a
210 widget to its default value.
211
212 \sa setProperty(), setWidgetProperty()
213*/
214
215QT_END_NAMESPACE
Combined button and popup list for selecting options.