1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the documentation of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | /*!
|
---|
43 | \page designer-manual.html
|
---|
44 |
|
---|
45 | \title Qt Designer Manual
|
---|
46 | \ingroup qttools
|
---|
47 | \keyword Qt Designer
|
---|
48 |
|
---|
49 | \QD is Qt's tool for designing and building graphical user
|
---|
50 | interfaces (GUIs) from Qt components. You can compose and customize your
|
---|
51 | widgets or dialogs in a what-you-see-is-what-you-get (WYSIWYG) manner, and
|
---|
52 | test them using different styles and resolutions.
|
---|
53 |
|
---|
54 | Widgets and forms created with \QD integrated seamlessly with programmed
|
---|
55 | code, using Qt's signals and slots mechanism, that lets you easily assign
|
---|
56 | behavior to graphical elements. All properties set in \QD can be changed
|
---|
57 | dynamically within the code. Furthermore, features like widget promotion
|
---|
58 | and custom plugins allow you to use your own components with \QD.
|
---|
59 |
|
---|
60 | If you are new to \QD, you can take a look at the
|
---|
61 | \l{Getting To Know Qt Designer} document. For a quick tutorial on how to
|
---|
62 | use \QD, refer to \l{A Quick Start to Qt Designer}.
|
---|
63 |
|
---|
64 | \image designer-multiple-screenshot.png
|
---|
65 |
|
---|
66 | For more information on using \QD, you can take a look at the following
|
---|
67 | links:
|
---|
68 |
|
---|
69 | \list
|
---|
70 | \o \l{Qt Designer's Editing Modes}
|
---|
71 | \list
|
---|
72 | \o \l{Qt Designer's Widget Editing Mode}{Widget Editing Mode}
|
---|
73 | \o \l{Qt Designer's Signals and Slots Editing Mode}
|
---|
74 | {Signals and Slots Editing Mode}
|
---|
75 | \o \l{Qt Designer's Buddy Editing Mode}
|
---|
76 | {Buddy Editing Mode}
|
---|
77 | \o \l{Qt Designer's Tab Order Editing Mode}
|
---|
78 | {Tab Order Editing Mode}
|
---|
79 | \endlist
|
---|
80 | \o \l{Using Layouts in Qt Designer}
|
---|
81 | \o \l{Saving, Previewing and Printing Forms in Qt Designer}
|
---|
82 | \o \l{Using Containers in Qt Designer}
|
---|
83 | \o \l{Creating Main Windows in Qt Designer}
|
---|
84 | \o \l{Editing Resources with Qt Designer}
|
---|
85 | \o \l{Using Stylesheets with Qt Designer}
|
---|
86 | \o \l{Using a Designer UI File in Your Application}
|
---|
87 | \endlist
|
---|
88 |
|
---|
89 | For advanced usage of \QD, you can refer to these links:
|
---|
90 |
|
---|
91 | \list
|
---|
92 | \o \l{Customizing Qt Designer Forms}
|
---|
93 | \o \l{Using Custom Widgets with Qt Designer}
|
---|
94 | \o \l{Creating Custom Widgets for Qt Designer}
|
---|
95 | \o \l{Creating Custom Widget Extensions}
|
---|
96 | \o \l{Qt Designer's UI File Format}
|
---|
97 | \endlist
|
---|
98 |
|
---|
99 |
|
---|
100 | \section1 Legal Notices
|
---|
101 |
|
---|
102 | Some source code in \QD is licensed under specific highly permissive
|
---|
103 | licenses from the original authors. The Qt team gratefully acknowledges
|
---|
104 | these contributions to \QD and all uses of \QD should also acknowledge
|
---|
105 | these contributions and quote the following license statements in an
|
---|
106 | appendix to the documentation.
|
---|
107 |
|
---|
108 | \list
|
---|
109 | \i \l{Implementation of the Recursive Shadow Casting Algorithm in Qt Designer}
|
---|
110 | \endlist
|
---|
111 | */
|
---|
112 |
|
---|
113 |
|
---|
114 | /*!
|
---|
115 | \page designer-to-know.html
|
---|
116 | \contentspage {Qt Designer Manual}{Contents}
|
---|
117 |
|
---|
118 |
|
---|
119 | \title Getting to Know Qt Designer
|
---|
120 |
|
---|
121 | \tableofcontents
|
---|
122 |
|
---|
123 | \image designer-screenshot.png
|
---|
124 |
|
---|
125 | \section1 Launching Designer
|
---|
126 |
|
---|
127 | The way that you launch \QD depends on your platform:
|
---|
128 |
|
---|
129 | \list
|
---|
130 | \i On Windows, click the Start button, under the \gui Programs submenu,
|
---|
131 | open the \gui{Qt 4} submenu and click \gui Designer.
|
---|
132 | \i On Unix or Linux, you might find a \QD icon on the desktop
|
---|
133 | background or in the desktop start menu under the \gui Programming
|
---|
134 | or \gui Development submenus. You can launch \QD from this icon.
|
---|
135 | Alternatively, you can type \c{designer} in a terminal window.
|
---|
136 | \i On Mac OS X, double click on \QD in \gui Finder.
|
---|
137 | \endlist
|
---|
138 |
|
---|
139 | \section1 The User Interface
|
---|
140 |
|
---|
141 | When used as a standalone application, \QD's user interface can be
|
---|
142 | configured to provide either a multi-window user interface (the default
|
---|
143 | mode), or it can be used in docked window mode. When used from within an
|
---|
144 | integrated development environment (IDE) only the multi-window user
|
---|
145 | interface is available. You can switch modes in the \gui Preferences dialog
|
---|
146 | from the \gui Edit menu.
|
---|
147 |
|
---|
148 | In multi-window mode, you can arrange each of the tool windows to suit your
|
---|
149 | working style. The main window consists of a menu bar, a tool bar, and a
|
---|
150 | widget box that contains the widgets you can use to create your user
|
---|
151 | interface.
|
---|
152 |
|
---|
153 | \target MainWindow
|
---|
154 | \table
|
---|
155 | \row
|
---|
156 | \i \inlineimage designer-main-window.png
|
---|
157 | \i \bold{Qt Designer's Main Window}
|
---|
158 |
|
---|
159 | The menu bar provides all the standard actions for managing forms,
|
---|
160 | using the clipboard, and accessing application-specific help.
|
---|
161 | The current editing mode, the tool windows, and the forms in use can
|
---|
162 | also be accessed via the menu bar.
|
---|
163 |
|
---|
164 | The tool bar displays common actions that are used when editing a form.
|
---|
165 | These are also available via the main menu.
|
---|
166 |
|
---|
167 | The widget box provides common widgets and layouts that are used to
|
---|
168 | design components. These are grouped into categories that reflect their
|
---|
169 | uses or features.
|
---|
170 | \endtable
|
---|
171 |
|
---|
172 | Most features of \QD are accessible via the menu bar, the tool bar, or the
|
---|
173 | widget box. Some features are also available through context menus that can
|
---|
174 | be opened over the form windows. On most platforms, the right mouse is used
|
---|
175 | to open context menus.
|
---|
176 |
|
---|
177 | \target WidgetBox
|
---|
178 | \table
|
---|
179 | \row
|
---|
180 | \i \inlineimage designer-widget-box.png
|
---|
181 | \i \bold{Qt Designer's Widget Box}
|
---|
182 |
|
---|
183 | The widget box provides a selection of standard Qt widgets, layouts,
|
---|
184 | and other objects that can be used to create user interfaces on forms.
|
---|
185 | Each of the categories in the widget box contain widgets with similar
|
---|
186 | uses or related features.
|
---|
187 |
|
---|
188 | \note Since Qt 4.4, new widgets have been included, e.g.,
|
---|
189 | QPlainTextEdit, QCommandLinkButton, QScrollArea, QMdiArea, and
|
---|
190 | QWebView.
|
---|
191 |
|
---|
192 | You can display all of the available objects in a category by clicking
|
---|
193 | on the handle next to the category label. When in
|
---|
194 | \l{Qt Designer's Widget Editing Mode}{Widget Editing
|
---|
195 | Mode}, you can add objects to a form by dragging the appropriate items
|
---|
196 | from the widget box onto the form, and dropping them in the required
|
---|
197 | locations.
|
---|
198 |
|
---|
199 | \QD provides a scratch pad feature that allows you to collect
|
---|
200 | frequently used objects in a separate category. The scratch pad
|
---|
201 | category can be filled with any widget currently displayed in a form
|
---|
202 | by dragging them from the form and dropping them onto the widget box.
|
---|
203 | These widgets can be used in the same way as any other widgets, but
|
---|
204 | they can also contain child widgets. Open a context menu over a widget
|
---|
205 | to change its name or remove it from the scratch pad.
|
---|
206 | \endtable
|
---|
207 |
|
---|
208 |
|
---|
209 | \section1 The Concept of Layouts in Qt
|
---|
210 |
|
---|
211 | A layout is used to arrange and manage the elements that make up a user
|
---|
212 | interface. Qt provides a number of classes to automatically handle layouts
|
---|
213 | -- QHBoxLayout, QVBoxLayout, QGridLayout, and QFormLayout. These classes
|
---|
214 | solve the challenge of laying out widgets automatically, providing a user
|
---|
215 | interface that behaves predictably. Fortunately knowledge of the layout
|
---|
216 | classes is not required to arrange widgets with \QD. Instead, select one of
|
---|
217 | the \gui{Lay Out Horizontally}, \gui{Lay Out in a Grid}, etc., options from
|
---|
218 | the context menu.
|
---|
219 |
|
---|
220 | Each Qt widget has a recommended size, known as \l{QWidget::}{sizeHint()}.
|
---|
221 | The layout manager will attempt to resize a widget to meet its size hint.
|
---|
222 | In some cases, there is no need to have a different size. For example, the
|
---|
223 | height of a QLineEdit is always a fixed value, depending on font size and
|
---|
224 | style. In other cases, you may require the size to change, e.g., the width
|
---|
225 | of a QLineEdit or the width and height of item view widgets. This is where
|
---|
226 | the widget size constraints -- \l{QWidget::minimumSize()}{minimumSize} and
|
---|
227 | \l{QWidget::maximumSize()}{maximumSize} constraints come into play. These
|
---|
228 | are properties you can set in the property editor. For example, to override
|
---|
229 | the default \l{QWidget::}{sizeHint()}, simply set
|
---|
230 | \l{QWidget::minimumSize()}{minimumSize} and \l{QWidget::maximumSize()}
|
---|
231 | {maximumSize} to the same value. Alternatively, to use the current size as
|
---|
232 | a size constraint value, choose one of the \gui{Size Constraint} options
|
---|
233 | from the widget's context menu. The layout will then ensure that those
|
---|
234 | constraints are met. To control the size of your widgets via code, you can
|
---|
235 | reimplement \l{QWidget::}{sizeHint()} in your code.
|
---|
236 |
|
---|
237 | The screenshot below shows the breakdown of a basic user interface designed
|
---|
238 | using a grid. The coordinates on the screenshot show the position of each
|
---|
239 | widget within the grid.
|
---|
240 |
|
---|
241 | \image addressbook-tutorial-part3-labeled-layout.png
|
---|
242 |
|
---|
243 | \note Inside the grid, the QPushButton objects are actually nested. The
|
---|
244 | buttons on the right are first placed in a QVBoxLayout; the buttons at the
|
---|
245 | bottom are first placed in a QHBoxLayout. Finally, they are put into
|
---|
246 | coordinates (1,2) and (3,1) of the QGridLayout.
|
---|
247 |
|
---|
248 | To visualize, imagine the layout as a box that shrinks as much as possible,
|
---|
249 | attempting to \e squeeze your widgets in a neat arrangement, and, at the
|
---|
250 | same time, maximize the use of available space.
|
---|
251 |
|
---|
252 | Qt's layouts help when you:
|
---|
253 |
|
---|
254 | \list 1
|
---|
255 | \i Resize the user face to fit different window sizes.
|
---|
256 | \i Resize elements within the user interface to suit different
|
---|
257 | localizations.
|
---|
258 | \i Arrange elements to adhere to layout guidelines for different
|
---|
259 | platforms.
|
---|
260 | \endlist
|
---|
261 |
|
---|
262 | So, you no longer have to worry about rearranging widgets for different
|
---|
263 | platforms, settings, and languages.
|
---|
264 |
|
---|
265 | The example below shows how different localizations can affect the user
|
---|
266 | interface. When a localization requires more space for longer text strings
|
---|
267 | the Qt layout automatically scales to accommodate this, while ensuring that
|
---|
268 | the user interface looks presentable and still matches the platform
|
---|
269 | guidelines.
|
---|
270 |
|
---|
271 | \table
|
---|
272 | \header
|
---|
273 | \i A Dialog in English
|
---|
274 | \i A Dialog in French
|
---|
275 | \row
|
---|
276 | \i \image designer-english-dialog.png
|
---|
277 | \i \image designer-french-dialog.png
|
---|
278 | \endtable
|
---|
279 |
|
---|
280 | The process of laying out widgets consists of creating the layout hierarchy
|
---|
281 | while setting as few widget size constraints as possible.
|
---|
282 |
|
---|
283 | For a more technical perspective on Qt's layout classes, refer to the
|
---|
284 | \l{Layout Management} documentation.
|
---|
285 | */
|
---|
286 |
|
---|
287 |
|
---|
288 | /*!
|
---|
289 | \page designer-quick-start.html
|
---|
290 | \contentspage {Qt Designer Manual}{Contents}
|
---|
291 |
|
---|
292 |
|
---|
293 | \title A Quick Start to Qt Designer
|
---|
294 |
|
---|
295 | Using \QD involves \bold four basic steps:
|
---|
296 |
|
---|
297 | \list 1
|
---|
298 | \o Choose your form and objects
|
---|
299 | \o Lay the objects out on the form
|
---|
300 | \o Connect the signals to the slots
|
---|
301 | \o Preview the form
|
---|
302 | \endlist
|
---|
303 |
|
---|
304 | \image rgbController-screenshot.png
|
---|
305 |
|
---|
306 | Suppose you would like to design a small widget (see screenshot above) that
|
---|
307 | contains the controls needed to manipulate Red, Green and Blue (RGB) values
|
---|
308 | -- a type of widget that can be seen everywhere in image manipulation
|
---|
309 | programs.
|
---|
310 |
|
---|
311 | \table
|
---|
312 | \row
|
---|
313 | \i \inlineimage designer-choosing-form.png
|
---|
314 | \i \bold{Choosing a Form}
|
---|
315 |
|
---|
316 | You start by choosing \gui Widget from the \gui{New Form} dialog.
|
---|
317 | \endtable
|
---|
318 |
|
---|
319 |
|
---|
320 | \table
|
---|
321 | \row
|
---|
322 | \i \inlineimage rgbController-arrangement.png
|
---|
323 | \i \bold{Placing Widgets on a Form}
|
---|
324 |
|
---|
325 | Drag three labels, three spin boxes and three vertical sliders on to your
|
---|
326 | form. To change the label's default text, simply double-click on it. You
|
---|
327 | can arrange them according to how you would like them to be laid out.
|
---|
328 | \endtable
|
---|
329 |
|
---|
330 | To ensure that they are laid out exactly like this in your program, you
|
---|
331 | need to place these widgets into a layout. We will do this in groups of
|
---|
332 | three. Select the "RED" label. Then, hold down \key Ctrl while you select
|
---|
333 | its corresponding spin box and slider. In the \gui{Form} menu, select
|
---|
334 | \gui{Lay Out in a Grid}.
|
---|
335 |
|
---|
336 | \table
|
---|
337 | \row
|
---|
338 | \i \inlineimage rgbController-form-gridLayout.png
|
---|
339 | \i \inlineimage rgbController-selectForLayout.png
|
---|
340 | \endtable
|
---|
341 |
|
---|
342 |
|
---|
343 | Repeat the step for the other two labels along with their corresponding
|
---|
344 | spin boxes and sliders as well.
|
---|
345 |
|
---|
346 | The next step is to combine all three layouts into one \bold{main layout}.
|
---|
347 | The main layout is the top level widget's (in this case, the QWidget)
|
---|
348 | layout. It is important that your top level widget has a layout; otherwise,
|
---|
349 | the widgets on your window will not resize when your window is resized. To
|
---|
350 | set the layout, \gui{Right click} anywhere on your form, outside of the
|
---|
351 | three separate layouts, and select \gui{Lay Out Horizontally}.
|
---|
352 | Alternatively, you could also select \gui{Lay Out in a Grid} -- you will
|
---|
353 | still see the same arrangement (shown below).
|
---|
354 |
|
---|
355 | \image rgbController-final-layout.png
|
---|
356 |
|
---|
357 | \note Main layouts cannot be seen on the form. To check if you have a main
|
---|
358 | layout installed, try resizing your form; your widgets should resize
|
---|
359 | accordingly. Alternatively, you can take a look at \QD's
|
---|
360 | \gui{Object Inspector}. If your top level widget does not have a layout,
|
---|
361 | you will see the broken layout icon next to it,
|
---|
362 | \inlineimage rgbController-no-toplevel-layout.png
|
---|
363 | .
|
---|
364 |
|
---|
365 | When you click on the slider and drag it to a certain value, you want the
|
---|
366 | spin box to display the slider's position. To accomplish this behavior, you
|
---|
367 | need to connect the slider's \l{QAbstractSlider::}{valueChanged()} signal
|
---|
368 | to the spin box's \l{QSpinBox::}{setValue()} slot. You also need to make
|
---|
369 | the reverse connections, e.g., connect the spin box's \l{QSpinBox::}
|
---|
370 | {valueChanged()} signal to the slider's \l{QAbstractSlider::value()}
|
---|
371 | {setValue()} slot.
|
---|
372 |
|
---|
373 | To do this, you have to switch to \gui{Edit Signals/Slots} mode, either by
|
---|
374 | pressing \key{F4} or selecting \gui{Edit Signals/Slots} from the \gui{Edit}
|
---|
375 | menu.
|
---|
376 |
|
---|
377 | \table
|
---|
378 | \row
|
---|
379 | \i \inlineimage rgbController-signalsAndSlots.png
|
---|
380 | \i \bold{Connecting Signals to Slots}
|
---|
381 |
|
---|
382 | Click on the slider and drag the cursor towards the spin box. The
|
---|
383 | \gui{Configure Connection} dialog, shown below, will pop up. Select the
|
---|
384 | correct signal and slot and click \gui OK.
|
---|
385 | \endtable
|
---|
386 |
|
---|
387 | \image rgbController-configure-connection1.png
|
---|
388 |
|
---|
389 | Repeat the step (in reverse order), clicking on the spin box and dragging
|
---|
390 | the cursor towards the slider, to connect the spin box's
|
---|
391 | \l{QSpinBox::}{valueChanged()} signal to the slider's
|
---|
392 | \l{QAbstractSlider::value()}{setValue()} slot.
|
---|
393 |
|
---|
394 | You can use the screenshot below as a guide to selecting the correct signal
|
---|
395 | and slot.
|
---|
396 |
|
---|
397 | \image rgbController-configure-connection2.png
|
---|
398 |
|
---|
399 | Now that you have successfully connected the objects for the "RED"
|
---|
400 | component of the RGB Controller, do the same for the "GREEN" and "BLUE"
|
---|
401 | components as well.
|
---|
402 |
|
---|
403 | Since RGB values range between 0 and 255, we need to limit the spin box
|
---|
404 | and slider to that particular range.
|
---|
405 |
|
---|
406 | \table
|
---|
407 | \row
|
---|
408 | \i \inlineimage rgbController-property-editing.png
|
---|
409 | \i \bold{Setting Widget Properties}
|
---|
410 |
|
---|
411 | Click on the first spin box. Within the \gui{Property Editor}, you will
|
---|
412 | see \l{QSpinBox}'s properties. Enter "255" for the
|
---|
413 | \l{QSpinBox::}{maximum} property. Then, click on the first vertical
|
---|
414 | slider, you will see \l{QAbstractSlider}'s properties. Enter "255" for
|
---|
415 | the \l{QAbstractSlider::}{maximum} property as well. Repeat this
|
---|
416 | process for the remaining spin boxes and sliders.
|
---|
417 | \endtable
|
---|
418 |
|
---|
419 | Now, we preview your form to see how it would look in your application -
|
---|
420 | press \key{Ctrl + R} or select \gui Preview from the \gui Form menu. Try
|
---|
421 | dragging the slider - the spin box will mirror its value too (and vice
|
---|
422 | versa). Also, you can resize it to see how the layouts that are used to
|
---|
423 | manage the child widgets, respond to different window sizes.
|
---|
424 | */
|
---|
425 |
|
---|
426 |
|
---|
427 | /*!
|
---|
428 | \page designer-editing-mode.html
|
---|
429 | \previouspage Getting to Know Qt Designer
|
---|
430 | \contentspage {Qt Designer Manual}{Contents}
|
---|
431 | \nextpage Using Layouts in Qt Designer
|
---|
432 |
|
---|
433 | \title Qt Designer's Editing Modes
|
---|
434 |
|
---|
435 | \QD provides four editing modes: \l{Qt Designer's Widget Editing Mode}
|
---|
436 | {Widget Editing Mode}, \l{Qt Designer's Signals and Slots Editing Mode}
|
---|
437 | {Signals and Slots Editing Mode}, \l{Qt Designer's Buddy Editing Mode}
|
---|
438 | {Buddy Editing Mode} and \l{Qt Designer's Tab Order Editing Mode}
|
---|
439 | {Tab Order Editing Mode}. When working with \QD, you will always be in one
|
---|
440 | of these four modes. To switch between modes, simply select it from the
|
---|
441 | \gui{Edit} menu or the toolbar. The table below describes these modes in
|
---|
442 | further detail.
|
---|
443 |
|
---|
444 | \table
|
---|
445 | \header \i \i \bold{Editing Modes}
|
---|
446 | \row
|
---|
447 | \i \inlineimage designer-widget-tool.png
|
---|
448 | \i In \l{Qt Designer's Widget Editing Mode}{Edit} mode, we can
|
---|
449 | change the appearance of the form, add layouts, and edit the
|
---|
450 | properties of each widget. To switch to this mode, press
|
---|
451 | \key{F3}. This is \QD's default mode.
|
---|
452 |
|
---|
453 | \row
|
---|
454 | \i \inlineimage designer-connection-tool.png
|
---|
455 | \i In \l{Qt Designer's Signals and Slots Editing Mode}
|
---|
456 | {Signals and Slots} mode, we can connect widgets together using
|
---|
457 | Qt's signals and slots mechanism. To switch to this mode, press
|
---|
458 | \key{F4}.
|
---|
459 |
|
---|
460 | \row
|
---|
461 | \i \inlineimage designer-buddy-tool.png
|
---|
462 | \i In \l{Qt Designer's Buddy Editing Mode}{Buddy Editing Mode},
|
---|
463 | buddy widgets can be assigned to label widgets to help them
|
---|
464 | handle keyboard focus correctly.
|
---|
465 |
|
---|
466 | \row
|
---|
467 | \i \inlineimage designer-tab-order-tool.png
|
---|
468 | \i In \l{Qt Designer's Tab Order Editing Mode}
|
---|
469 | {Tab Order Editing Mode}, we can set the order in which widgets
|
---|
470 | receive the keyboard focus.
|
---|
471 | \endtable
|
---|
472 |
|
---|
473 | */
|
---|
474 |
|
---|
475 |
|
---|
476 | /*!
|
---|
477 | \page designer-widget-mode.html
|
---|
478 | \previouspage Qt Designer's Editing Modes
|
---|
479 | \contentspage {Qt Designer Manual}{Contents}
|
---|
480 | \nextpage Qt Designer's Signals and Slots Editing Mode
|
---|
481 |
|
---|
482 | \title Qt Designer's Widget Editing Mode
|
---|
483 |
|
---|
484 | \image designer-editing-mode.png
|
---|
485 |
|
---|
486 | In the Widget Editing Mode, objects can be dragged from the main window's
|
---|
487 | widget box to a form, edited, resized, dragged around on the form, and even
|
---|
488 | dragged between forms. Object properties can be modified interactively, so
|
---|
489 | that changes can be seen immediately. The editing interface is intuitive
|
---|
490 | for simple operations, yet it still supports Qt's powerful layout
|
---|
491 | facilities.
|
---|
492 |
|
---|
493 |
|
---|
494 | \tableofcontents
|
---|
495 |
|
---|
496 | To create and edit new forms, open the \gui File menu and select
|
---|
497 | \gui{New Form...} or press \key{Ctrl+N}. Existing forms can also be edited
|
---|
498 | by selecting \gui{Open Form...} from the \gui File menu or pressing
|
---|
499 | \key{Ctrl+O}.
|
---|
500 |
|
---|
501 | At any point, you can save your form by selecting the \gui{Save From As...}
|
---|
502 | option from the \gui File menu. The UI files saved by \QD contain
|
---|
503 | information about the objects used, and any details of signal and slot
|
---|
504 | connections between them.
|
---|
505 |
|
---|
506 |
|
---|
507 | \section1 Editing A Form
|
---|
508 |
|
---|
509 | By default, new forms are opened in widget editing mode. To switch to Edit
|
---|
510 | mode from another mode, select \gui{Edit Widgets} from the \gui Edit menu
|
---|
511 | or press the \key F3 key.
|
---|
512 |
|
---|
513 | Objects are added to the form by dragging them from the main widget box
|
---|
514 | and dropping them in the desired location on the form. Once there, they
|
---|
515 | can be moved around simply by dragging them, or using the cursor keys.
|
---|
516 | Pressing the \key Ctrl key at the same time moves the selected widget
|
---|
517 | pixel by pixel, while using the cursor keys alone make the selected widget
|
---|
518 | snap to the grid when it is moved. Objects can be selected by clicking on
|
---|
519 | them with the left mouse button. You can also use the \key Tab key to
|
---|
520 | change the selection.
|
---|
521 |
|
---|
522 | ### Screenshot of widget box, again
|
---|
523 |
|
---|
524 | The widget box contains objects in a number of different categories, all of
|
---|
525 | which can be placed on the form as required. The only objects that require
|
---|
526 | a little more preparation are the \gui Container widgets. These are
|
---|
527 | described in further detail in the \l{Using Containers in Qt Designer}
|
---|
528 | chapter.
|
---|
529 |
|
---|
530 |
|
---|
531 | \target SelectingObjects
|
---|
532 | \table
|
---|
533 | \row
|
---|
534 | \i \inlineimage designer-selecting-widget.png
|
---|
535 | \i \bold{Selecting Objects}
|
---|
536 |
|
---|
537 | Objects on the form are selected by clicking on them with the left
|
---|
538 | mouse button. When an object is selected, resize handles are shown at
|
---|
539 | each corner and the midpoint of each side, indicating that it can be
|
---|
540 | resized.
|
---|
541 |
|
---|
542 | To select additional objects, hold down the \key Shift key and click on
|
---|
543 | them. If more than one object is selected, the current object will be
|
---|
544 | displayed with resize handles of a different color.
|
---|
545 |
|
---|
546 | To move a widget within a layout, hold down \key Shift and \key Control
|
---|
547 | while dragging the widget. This extends the selection to the widget's
|
---|
548 | parent layout.
|
---|
549 |
|
---|
550 | Alternatively, objects can be selected in the
|
---|
551 | \l{The Object Inspector}{Object Inspector}.
|
---|
552 | \endtable
|
---|
553 |
|
---|
554 | When a widget is selected, normal clipboard operations such as cut, copy,
|
---|
555 | and paste can be performed on it. All of these operations can be done and
|
---|
556 | undone, as necessary.
|
---|
557 |
|
---|
558 | The following shortcuts can be used:
|
---|
559 |
|
---|
560 | \target ShortcutsForEditing
|
---|
561 | \table
|
---|
562 | \header \i Action \i Shortcut \i Description
|
---|
563 | \row
|
---|
564 | \i Cut
|
---|
565 | \i \key{Ctrl+X}
|
---|
566 | \i Cuts the selected objects to the clipboard.
|
---|
567 | \row
|
---|
568 | \i Copy
|
---|
569 | \i \key{Ctrl+C}
|
---|
570 | \i Copies the selected objects to the clipboard.
|
---|
571 | \row
|
---|
572 | \i Paste
|
---|
573 | \i \key{Ctrl+V}
|
---|
574 | \i Pastes the objects in the clipboard onto the form.
|
---|
575 | \row
|
---|
576 | \i Delete
|
---|
577 | \i \key Delete
|
---|
578 | \i Deletes the selected objects.
|
---|
579 | \row
|
---|
580 | \i Clone object
|
---|
581 | \i \key{Ctrl+drag} (leftmouse button)
|
---|
582 | \i Makes a copy of the selected object or group of objects.
|
---|
583 | \row
|
---|
584 | \i Preview
|
---|
585 | \i \key{Ctrl+R}
|
---|
586 | \i Shows a preview of the form.
|
---|
587 | \endtable
|
---|
588 |
|
---|
589 | All of the above actions (apart from cloning) can be accessed via both the
|
---|
590 | \gui Edit menu and the form's context menu. These menus also provide
|
---|
591 | funcitons for laying out objects as well as a \gui{Select All} function to
|
---|
592 | select all the objects on the form.
|
---|
593 |
|
---|
594 | Widgets are not unique objects; you can make as many copies of them as you
|
---|
595 | need. To quickly duplicate a widget, you can clone it by holding down the
|
---|
596 | \key Ctrl key and dragging it. This allows widgets to be copied and placed
|
---|
597 | on the form more quickly than with clipboard operations.
|
---|
598 |
|
---|
599 |
|
---|
600 | \target DragAndDrop
|
---|
601 | \table
|
---|
602 | \row
|
---|
603 | \i \inlineimage designer-dragging-onto-form.png
|
---|
604 | \i \bold{Drag and Drop}
|
---|
605 |
|
---|
606 | \QD makes extensive use of the drag and drop facilities provided by Qt.
|
---|
607 | Widgets can be dragged from the widget box and dropped onto the form.
|
---|
608 |
|
---|
609 | Widgets can also be "cloned" on the form: Holding down \key Ctrl and
|
---|
610 | dragging the widget creates a copy of the widget that can be dragged to
|
---|
611 | a new position.
|
---|
612 |
|
---|
613 | It is also possible to drop Widgets onto the \l {The Object Inspector}
|
---|
614 | {Object Inspector} to handle nested layouts easily.
|
---|
615 | \endtable
|
---|
616 |
|
---|
617 | \QD allows selections of objects to be copied, pasted, and dragged between
|
---|
618 | forms. You can use this feature to create more than one copy of the same
|
---|
619 | form, and experiment with different layouts in each of them.
|
---|
620 |
|
---|
621 |
|
---|
622 | \section2 The Property Editor
|
---|
623 |
|
---|
624 | The Property Editor always displays properties of the currently selected
|
---|
625 | object on the form. The available properties depend on the object being
|
---|
626 | edited, but all of the widgets provided have common properties such as
|
---|
627 | \l{QObject::}{objectName}, the object's internal name, and
|
---|
628 | \l{QWidget::}{enabled}, the property that determines whether an
|
---|
629 | object can be interacted with or not.
|
---|
630 |
|
---|
631 |
|
---|
632 | \target EditingProperties
|
---|
633 | \table
|
---|
634 | \row
|
---|
635 | \i \inlineimage designer-property-editor.png
|
---|
636 | \i \bold{Editing Properties}
|
---|
637 |
|
---|
638 | The property editor uses standard Qt input widgets to manage the
|
---|
639 | properties of jbects on the form. Textual properties are shown in line
|
---|
640 | edits, integer properties are displayed in spinboxes, boolean
|
---|
641 | properties are displayed in check boxes, and compound properties such
|
---|
642 | as colors and sizes are presented in drop-down lists of input widgets.
|
---|
643 |
|
---|
644 | Modified properties are indicated with bold labels. To reset them, click
|
---|
645 | the arrow button on the right.
|
---|
646 |
|
---|
647 | Changes in properties are applied to all selected objects that have the
|
---|
648 | same property.
|
---|
649 | \endtable
|
---|
650 |
|
---|
651 | Certain properties are treated specially by the property editor:
|
---|
652 |
|
---|
653 | \list
|
---|
654 | \o Compound properties -- properties that are made up of more than one
|
---|
655 | value -- are represented as nodes that can be expanded, allowing
|
---|
656 | their values to be edited.
|
---|
657 | \o Properties that contain a choice or selection of flags are edited
|
---|
658 | via combo boxes with checkable items.
|
---|
659 | \o Properties that allow access to rich data types, such as QPalette,
|
---|
660 | are modified using dialogs that open when the properties are edited.
|
---|
661 | QLabel and the widgets in the \gui Buttons section of the widget box
|
---|
662 | have a \c text property that can also be edited by double-clicking
|
---|
663 | on the widget or by pressing \gui F2. \QD interprets the backslash
|
---|
664 | (\\) character specially, enabling newline (\\n) characters to be
|
---|
665 | inserted into the text; the \\\\ character sequence is used to
|
---|
666 | insert a single backslash into the text. A context menu can also be
|
---|
667 | opened while editing, providing another way to insert special
|
---|
668 | characters and newlines into the text.
|
---|
669 | \endlist
|
---|
670 |
|
---|
671 |
|
---|
672 | \section2 Dynamic Properties
|
---|
673 |
|
---|
674 | The property editor can also be used to add new
|
---|
675 | \l{QObject#Dynamic Properties}{dynamic properties} to both standard Qt
|
---|
676 | widgets and to forms themselves. Since Qt 4.4, dynamic properties are added
|
---|
677 | and removed via the property editor's toolbar, shown below.
|
---|
678 |
|
---|
679 | \image designer-property-editor-toolbar.png
|
---|
680 |
|
---|
681 | To add a dynamic property, clcik on the \gui Add button
|
---|
682 | \inlineimage designer-property-editor-add-dynamic.png
|
---|
683 | . To remove it, click on the \gui Remove button
|
---|
684 | \inlineimage designer-property-editor-remove-dynamic.png
|
---|
685 | instead. You can also sort the properties alphabetically and change the
|
---|
686 | color groups by clickinig on the \gui Configure button
|
---|
687 | \inlineimage designer-property-editor-configure.png
|
---|
688 | .
|
---|
689 |
|
---|
690 | \section2 The Object Inspector
|
---|
691 | \table
|
---|
692 | \row
|
---|
693 | \i \inlineimage designer-object-inspector.png
|
---|
694 | \i \bold{The Object Inspector}
|
---|
695 |
|
---|
696 | The \gui{Object Inspector} displays a hierarchical list of all the
|
---|
697 | objects on the form that is currently being edited. To show the child
|
---|
698 | objects of a container widget or a layout, click the handle next to the
|
---|
699 | object label.
|
---|
700 |
|
---|
701 | Each object on a form can be selected by clicking on the corresponding
|
---|
702 | item in the \gui{Object Inspector}. Right-clicking opens the form's
|
---|
703 | context menu. These features can be useful if you have many overlapping
|
---|
704 | objects. To locate an object in the \gui{Object Inspector}, use
|
---|
705 | \key{Ctrl+F}.
|
---|
706 |
|
---|
707 | Since Qt 4.4, double-clicking on the object's name allows you to change
|
---|
708 | the object's name with the in-place editor.
|
---|
709 |
|
---|
710 | Since Qt 4.5, the \gui{Object Inspector} displays the layout state of
|
---|
711 | the containers. The broken layout icon ###ICON is displayed if there is
|
---|
712 | something wrong with the layouts.
|
---|
713 |
|
---|
714 | \endtable
|
---|
715 | */
|
---|
716 |
|
---|
717 |
|
---|
718 | /*!
|
---|
719 | \page designer-layouts.html
|
---|
720 | \previouspage Qt Designer's Widget Editing Mode
|
---|
721 | \contentspage
|
---|
722 | \nextpage Qt Designer's Signals and Slots Editing Mode
|
---|
723 |
|
---|
724 | \title Using Layouts in Qt Designer
|
---|
725 |
|
---|
726 | Before a form can be used, the objects on the form need to be placed into
|
---|
727 | layouts. This ensures that the objects will be displayed properly when the
|
---|
728 | form is previewed or used in an application. Placing objects in a layout
|
---|
729 | also ensures that they will be resized correctly when the form is resized.
|
---|
730 |
|
---|
731 |
|
---|
732 | \tableofcontents
|
---|
733 |
|
---|
734 | \section1 Applying and Breaking Layouts
|
---|
735 |
|
---|
736 | The simplest way to manage objects is to apply a layout to a group of
|
---|
737 | existing objects. This is achieved by selecting the objects that you need
|
---|
738 | to manage and applying one of the standard layouts using the main toolbar,
|
---|
739 | the \gui Form menu, or the form's context menu.
|
---|
740 |
|
---|
741 | Once widgets have been inserted into a layout, it is not possible to move
|
---|
742 | and resize them individually because the layout itself controls the
|
---|
743 | geometry of each widget within it, taking account of the hints provided by
|
---|
744 | spacers. Instead, you must either break the layout and adjust each object's
|
---|
745 | geometry manually, or you can influence the widget's geometry by resizing
|
---|
746 | the layout.
|
---|
747 |
|
---|
748 | To break the layout, press \key{Ctrl+0} or choose \gui{Break Layout} from
|
---|
749 | the form's context menu, the \gui Form menu or the main toolbar. You can
|
---|
750 | also add and remove spacers from the layout to influence the geometries of
|
---|
751 | the widgets.
|
---|
752 |
|
---|
753 |
|
---|
754 | \target InsertingObjectsIntoALayout
|
---|
755 | \table
|
---|
756 | \row
|
---|
757 | \i \inlineimage designer-layout-inserting.png
|
---|
758 | \i \bold{Inserting Objects into a Layout}
|
---|
759 |
|
---|
760 | Objects can be inserted into an existing layout by dragging them from
|
---|
761 | their current positions and dropping them at the required location. A
|
---|
762 | blue cursor is displayed in the layout as an object is dragged over
|
---|
763 | it to indicate where the object will be added.
|
---|
764 | \endtable
|
---|
765 |
|
---|
766 |
|
---|
767 | \section2 Setting A Top Level Layout
|
---|
768 |
|
---|
769 | The form's top level layout can be set by clearing the slection (click the
|
---|
770 | left mouse button on the form itself) and applying a layout. A top level
|
---|
771 | layout is necessary to ensure that your widgets will resize correctly when
|
---|
772 | its window is resized. To check if you have set a top level layout, preview
|
---|
773 | your widget and attempt to resize the window by dragging the size grip.
|
---|
774 |
|
---|
775 | \table
|
---|
776 | \row
|
---|
777 | \i \inlineimage designer-set-layout.png
|
---|
778 | \i \bold{Applying a Layout}
|
---|
779 |
|
---|
780 | To apply a layout, you can select your choice of layout from the
|
---|
781 | toolbar shown on the left, or from the context menu shown below.
|
---|
782 | \endtable
|
---|
783 |
|
---|
784 | \image designer-set-layout2.png
|
---|
785 |
|
---|
786 |
|
---|
787 | \section2 Horizontal and Vertical Layouts
|
---|
788 |
|
---|
789 | The simplest way to arrange objects on a form is to place them in a
|
---|
790 | horizontal or vertical layout. Horizontal layouts ensure that the widgets
|
---|
791 | within are aligned horizontally; vertical layouts ensure that they are
|
---|
792 | aligned vertically.
|
---|
793 |
|
---|
794 | Horizontal and vertical layouts can be combined and nested to any depth.
|
---|
795 | However, if you need more control over the placement of objects, consider
|
---|
796 | using the grid layout.
|
---|
797 |
|
---|
798 |
|
---|
799 | \section3 The Grid Layout
|
---|
800 |
|
---|
801 | Complex form layouts can be created by placing objects in a grid layout.
|
---|
802 | This kind of layout gives the form designer much more freedom to arrange
|
---|
803 | widgets on the form, but can result in a much less flexible layout.
|
---|
804 | However, for some kinds of form layout, a grid arrangement is much more
|
---|
805 | suitable than a nested arrangement of horizontal and vertical layouts.
|
---|
806 |
|
---|
807 |
|
---|
808 | \section3 Splitter Layouts
|
---|
809 |
|
---|
810 | Another common way to manage the layout of objects on a form is to place
|
---|
811 | them in a splitter. These splitters arrange the objects horizontally or
|
---|
812 | vertically in the same way as normal layouts, but also allow the user to
|
---|
813 | adjust the amount of space allocated to each object.
|
---|
814 |
|
---|
815 | \image designer-splitter-layout.png
|
---|
816 |
|
---|
817 | Although QSplitter is a container widget, \QD treats splitter objects as
|
---|
818 | layouts that are applied to existing widgets. To place a group of widgets
|
---|
819 | into a splitter, select them
|
---|
820 | \l{Qt Designer's Widget Editing Mode#SelectingObjects}{as described here}
|
---|
821 | then apply the splitter layout by using the appropriate toolbar button,
|
---|
822 | keyboard shortcut, or \gui{Lay out} context menu entry.
|
---|
823 |
|
---|
824 |
|
---|
825 | \section3 The Form Layout
|
---|
826 |
|
---|
827 | Since Qt 4.4, another layout class has been included -- QFormLayout. This
|
---|
828 | class manages widgets in a two-column form; the left column holds labels
|
---|
829 | and the right column holds field widgets such as line edits, spin boxes,
|
---|
830 | etc. The QFormLayout class adheres to various platform look and feel
|
---|
831 | guidelines and supports wrapping for long rows.
|
---|
832 |
|
---|
833 | \image designer-form-layout.png
|
---|
834 |
|
---|
835 | The UI file above results in the previews shown below.
|
---|
836 |
|
---|
837 | \table
|
---|
838 | \header
|
---|
839 | \i Windows XP
|
---|
840 | \i Mac OS X
|
---|
841 | \i Cleanlooks
|
---|
842 | \row
|
---|
843 | \i \inlineimage designer-form-layout-windowsXP.png
|
---|
844 | \i \inlineimage designer-form-layout-macintosh.png
|
---|
845 | \i \inlineimage designer-form-layout-cleanlooks.png
|
---|
846 | \endtable
|
---|
847 |
|
---|
848 |
|
---|
849 | \section2 Shortcut Keys
|
---|
850 |
|
---|
851 | In addition to the standard toolbar and context menu entries, there is also
|
---|
852 | a set of keyboard shortcuts to apply layouts on widgets.
|
---|
853 |
|
---|
854 | \target LayoutShortcuts
|
---|
855 | \table
|
---|
856 | \header
|
---|
857 | \i Layout
|
---|
858 | \i Shortcut
|
---|
859 | \i Description
|
---|
860 | \row
|
---|
861 | \i Horizontal
|
---|
862 | \i \key{Ctrl+1}
|
---|
863 | \i Places the selected objects in a horizontal layout.
|
---|
864 | \row
|
---|
865 | \i Vertical
|
---|
866 | \i \key{Ctrl+2}
|
---|
867 | \i Places the selected objects in a vertical layout.
|
---|
868 | \row
|
---|
869 | \i Grid
|
---|
870 | \i \key{Ctrl+5}
|
---|
871 | \i Places the selected objects in a grid layout.
|
---|
872 | \row
|
---|
873 | \i Form
|
---|
874 | \i \key{Ctrl+6}
|
---|
875 | \i Places the selected objects in a form layout.
|
---|
876 | \row
|
---|
877 | \i Horizontal splitter
|
---|
878 | \i \key{Ctrl+3}
|
---|
879 | \i Creates a horizontal splitter and places the selected objects
|
---|
880 | inside it.
|
---|
881 | \row
|
---|
882 | \i Vertical splitter
|
---|
883 | \i \key{Ctrl+4}
|
---|
884 | \i Creates a vertical splitter and places the selected objects
|
---|
885 | inside it.
|
---|
886 | \row
|
---|
887 | \i Adjust size
|
---|
888 | \i \key{Ctrl+J}
|
---|
889 | \i Adjusts the size of the layout to ensure that each child object
|
---|
890 | has sufficient space to display its contents. See
|
---|
891 | QWidget::adjustSize() for more information.
|
---|
892 | \endtable
|
---|
893 |
|
---|
894 | \note \key{Ctrl+0} is used to break a layout.
|
---|
895 |
|
---|
896 | */
|
---|
897 |
|
---|
898 |
|
---|
899 | /*!
|
---|
900 | \page designer-preview.html
|
---|
901 | \contentspage {Qt Designer Manual}{Contents}
|
---|
902 | \previouspage Using Layouts in Qt Designer
|
---|
903 | \nextpage Qt Designer's Buddy Editing Mode
|
---|
904 | \title Saving, Previewing and Printing Forms in Qt Designer
|
---|
905 |
|
---|
906 | Although \QD's forms are accurate representations of the components being
|
---|
907 | edited, it is useful to preview the final appearance while editing. This
|
---|
908 | feature can be activated by opening the \gui Form menu and selecting
|
---|
909 | \gui Preview, or by pressing \key{Ctrl+R} when in the form.
|
---|
910 |
|
---|
911 | \image designer-dialog-preview.png
|
---|
912 |
|
---|
913 | The preview shows exactly what the final component will look like when used
|
---|
914 | in an application.
|
---|
915 |
|
---|
916 | Since Qt 4.4, it is possible to preview forms with various skins - default
|
---|
917 | skins, skins created with Qt Style Sheets or device skins. This feature
|
---|
918 | simulates the effect of calling \c{QApplication::setStyleSheet()} in the
|
---|
919 | application.
|
---|
920 |
|
---|
921 | To preview your form with skins, open the \gui Edit menu and select
|
---|
922 | \gui{Preferences...}
|
---|
923 |
|
---|
924 | You will see the dialog shown below:
|
---|
925 |
|
---|
926 | \image designer-preview-style.png
|
---|
927 |
|
---|
928 | The \gui{Print/Preview Configuration} checkbox must be checked to activate
|
---|
929 | previews of skins. You can select the styles provided from the \gui{Style}
|
---|
930 | drop-down box.
|
---|
931 |
|
---|
932 | \image designer-preview-style-selection.png
|
---|
933 |
|
---|
934 | Alternatively, you can preview custom style sheet created with Qt Style
|
---|
935 | Sheets. The figure below shows an example of Qt Style Sheet syntax and the
|
---|
936 | corresponding output.
|
---|
937 |
|
---|
938 | \image designer-preview-stylesheet.png
|
---|
939 |
|
---|
940 | Another option would be to preview your form with device skins. A list of
|
---|
941 | generic device skins are available in \QD, however, you may also use
|
---|
942 | other QVFB skins with the \gui{Browse...} option.
|
---|
943 |
|
---|
944 | \image designer-preview-deviceskin-selection.png
|
---|
945 |
|
---|
946 |
|
---|
947 | \section1 Viewing the Form's Code
|
---|
948 |
|
---|
949 | Since Qt 4.4, it is possible to view code generated by the User Interface
|
---|
950 | Compiler (uic) for the \QD form.
|
---|
951 |
|
---|
952 | \image designer-form-viewcode.png
|
---|
953 |
|
---|
954 | Select \gui{View Code...} from the \gui{Form} menu and a dialog with the
|
---|
955 | generated code will be displayed. The screenshot below is an example of
|
---|
956 | code generated by the \c{uic}.
|
---|
957 |
|
---|
958 | \image designer-code-viewer.png
|
---|
959 |
|
---|
960 | \section1 Saving and Printing the Form
|
---|
961 |
|
---|
962 | Forms created in \QD can be saved to an image or printed.
|
---|
963 |
|
---|
964 | \table
|
---|
965 | \row
|
---|
966 | \i \inlineimage designer-file-menu.png
|
---|
967 | \i \bold{Saving Forms}
|
---|
968 |
|
---|
969 | To save a form as an image, choose the \gui{Save Image...} option. The file
|
---|
970 | will be saved in \c{.png} format.
|
---|
971 |
|
---|
972 | \bold{Printing Forms}
|
---|
973 |
|
---|
974 | To print a form, select the \gui{Print...} option.
|
---|
975 |
|
---|
976 | \endtable
|
---|
977 | */
|
---|
978 |
|
---|
979 |
|
---|
980 | /*!
|
---|
981 | \page designer-connection-mode.html
|
---|
982 | \contentspage {Qt Designer Manual}{Contents}
|
---|
983 | \previouspage Using Layouts in Qt Designer
|
---|
984 | \nextpage Qt Designer's Buddy Editing Mode
|
---|
985 |
|
---|
986 |
|
---|
987 | \title Qt Designer's Signals and Slots Editing Mode
|
---|
988 |
|
---|
989 | \image designer-connection-mode.png
|
---|
990 |
|
---|
991 | In \QD's signals and slots editing mode, you can connect objects in a form
|
---|
992 | together using Qt's signals and slots mechanism. Both widgets and layouts
|
---|
993 | can be connected via an intuitive connection interface, using the menu of
|
---|
994 | compatible signals and slots provided by \QD. When a form is saved, all
|
---|
995 | connections are preserved so that they will be ready for use when your
|
---|
996 | project is built.
|
---|
997 |
|
---|
998 |
|
---|
999 | \tableofcontents
|
---|
1000 |
|
---|
1001 | For more information on Qt's signals and sltos mechanism, refer to the
|
---|
1002 | \l{Signals and Slots} document.
|
---|
1003 |
|
---|
1004 |
|
---|
1005 | \section1 Connecting Objects
|
---|
1006 |
|
---|
1007 | To begin connecting objects, enter the signals and slots editing mode by
|
---|
1008 | opening the \gui Edit menu and selecting \gui{Edit Signals/Slots}, or by
|
---|
1009 | pressing the \key F4 key.
|
---|
1010 |
|
---|
1011 | All widgets and layouts on the form can be connected together. However,
|
---|
1012 | spacers just provide spacing hints to layouts, so they cannot be connected
|
---|
1013 | to other objects.
|
---|
1014 |
|
---|
1015 |
|
---|
1016 | \target HighlightedObjects
|
---|
1017 | \table
|
---|
1018 | \row
|
---|
1019 | \i \inlineimage designer-connection-highlight.png
|
---|
1020 | \i \bold{Highlighted Objects}
|
---|
1021 |
|
---|
1022 | When the cursor is over an object that can be used in a connection, the
|
---|
1023 | object will be highlighted.
|
---|
1024 | \endtable
|
---|
1025 |
|
---|
1026 | To make a connectionn, press the left mouse button and drag the cursor
|
---|
1027 | towards the object you want to connect it to. As you do this, a line will
|
---|
1028 | extend from the source object to the cursor. If the cursor is over another
|
---|
1029 | object on the form, the line will end with an arrow head that points to the
|
---|
1030 | destination object. This indicates that a connection will be made between
|
---|
1031 | the two objects when you release the mouse button.
|
---|
1032 |
|
---|
1033 | You can abandon the connection at any point while you are dragging the
|
---|
1034 | connection path by pressing \key{Esc}.
|
---|
1035 |
|
---|
1036 | \target MakingAConnection
|
---|
1037 | \table
|
---|
1038 | \row
|
---|
1039 | \i \inlineimage designer-connection-making.png
|
---|
1040 | \i \bold{Making a Connection}
|
---|
1041 |
|
---|
1042 | The connection path will change its shape as the cursor moves around
|
---|
1043 | the form. As it passes over objects, they are highlighted, indicating
|
---|
1044 | that they can be used in a signal and slot connection. Release the
|
---|
1045 | mouse button to make the connection.
|
---|
1046 | \endtable
|
---|
1047 |
|
---|
1048 | The \gui{Configure Connection} dialog (below) is displayed, showing signals
|
---|
1049 | from the source object and slots from the destination object that you can
|
---|
1050 | use.
|
---|
1051 |
|
---|
1052 | \image designer-connection-dialog.png
|
---|
1053 |
|
---|
1054 | To complete the connection, select a signal from the source object and a
|
---|
1055 | slot from the destination object, then click \key OK. Click \key Cancel if
|
---|
1056 | you wish to abandon the connection.
|
---|
1057 |
|
---|
1058 | \note If the \gui{Show all signals and slots} checkbox is selected, all
|
---|
1059 | available signals from the source object will be shown. Otherwise, the
|
---|
1060 | signals and slots inherited from QWidget will be hidden.
|
---|
1061 |
|
---|
1062 | You can make as many connections as you like between objects on the form;
|
---|
1063 | it is possible to connect signals from objects to slots in the form itself.
|
---|
1064 | As a result, the signal and slot connections in many dialogs can be
|
---|
1065 | completely configured from within \QD.
|
---|
|
---|