replace \key and \gui qdoc commands with \uicontrol
Change-Id: I0753305d4fe1ea20417f451766101da1247dfeeb Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
This commit is contained in:
parent
d61c356516
commit
a68577e7e0
@ -46,7 +46,7 @@
|
|||||||
The address book contains 5 classes: \c MainWindow,
|
The address book contains 5 classes: \c MainWindow,
|
||||||
\c AddressWidget, \c TableModel, \c NewAddressTab and
|
\c AddressWidget, \c TableModel, \c NewAddressTab and
|
||||||
\c AddDialog. The \c MainWindow class uses \c AddressWidget as
|
\c AddDialog. The \c MainWindow class uses \c AddressWidget as
|
||||||
its central widget and provides \gui File and \gui Tools menus.
|
its central widget and provides \uicontrol File and \uicontrol Tools menus.
|
||||||
|
|
||||||
\image addressbook-classes.png Diagram for Address Book Example
|
\image addressbook-classes.png Diagram for Address Book Example
|
||||||
|
|
||||||
@ -223,8 +223,8 @@
|
|||||||
\l{QItemSelectionModel::selectionChanged()}{selectionChanged}
|
\l{QItemSelectionModel::selectionChanged()}{selectionChanged}
|
||||||
signal that is connected to \c{AddressWidget}'s
|
signal that is connected to \c{AddressWidget}'s
|
||||||
\c selectionChanged() signal. This signal to signal connection
|
\c selectionChanged() signal. This signal to signal connection
|
||||||
is necessary to enable the \gui{Edit Entry...} and
|
is necessary to enable the \uicontrol{Edit Entry...} and
|
||||||
\gui{Remove Entry} actions in \c MainWindow's Tools menu. This
|
\uicontrol{Remove Entry} actions in \c MainWindow's Tools menu. This
|
||||||
connection is further explained in \c MainWindow's
|
connection is further explained in \c MainWindow's
|
||||||
implementation.
|
implementation.
|
||||||
|
|
||||||
@ -241,7 +241,7 @@
|
|||||||
\c newAddressTab to insert data without having to popup a dialog.
|
\c newAddressTab to insert data without having to popup a dialog.
|
||||||
|
|
||||||
The first \c addEntry() function is a slot connected to the
|
The first \c addEntry() function is a slot connected to the
|
||||||
\c MainWindow's \gui{Add Entry...} action. This function creates an
|
\c MainWindow's \uicontrol{Add Entry...} action. This function creates an
|
||||||
\c AddDialog object and then calls the second \c addEntry()
|
\c AddDialog object and then calls the second \c addEntry()
|
||||||
function to actually add the contact to \c table.
|
function to actually add the contact to \c table.
|
||||||
|
|
||||||
@ -359,8 +359,8 @@
|
|||||||
|
|
||||||
\snippet itemviews/addressbook/adddialog.cpp 0
|
\snippet itemviews/addressbook/adddialog.cpp 0
|
||||||
|
|
||||||
To give the dialog the desired behavior, we connect the \gui OK
|
To give the dialog the desired behavior, we connect the \uicontrol OK
|
||||||
and \gui Cancel buttons to the dialog's \l{QDialog::}{accept()} and
|
and \uicontrol Cancel buttons to the dialog's \l{QDialog::}{accept()} and
|
||||||
\l{QDialog::}{reject()} slots. Since the dialog only acts as a
|
\l{QDialog::}{reject()} slots. Since the dialog only acts as a
|
||||||
container for name and address information, we do not need to
|
container for name and address information, we do not need to
|
||||||
implement any other functions for it.
|
implement any other functions for it.
|
||||||
@ -379,9 +379,9 @@
|
|||||||
\snippet itemviews/addressbook/mainwindow.h 0
|
\snippet itemviews/addressbook/mainwindow.h 0
|
||||||
|
|
||||||
The \c MainWindow class uses an \c AddressWidget as its central
|
The \c MainWindow class uses an \c AddressWidget as its central
|
||||||
widget and provides the File menu with \gui Open, \gui Close and
|
widget and provides the File menu with \uicontrol Open, \uicontrol Close and
|
||||||
\gui Exit actions, as well as the \gui Tools menu with
|
\uicontrol Exit actions, as well as the \uicontrol Tools menu with
|
||||||
\gui{Add Entry...}, \gui{Edit Entry...} and \gui{Remove Entry}
|
\uicontrol{Add Entry...}, \uicontrol{Edit Entry...} and \uicontrol{Remove Entry}
|
||||||
actions.
|
actions.
|
||||||
|
|
||||||
|
|
||||||
@ -393,9 +393,9 @@
|
|||||||
|
|
||||||
\snippet itemviews/addressbook/mainwindow.cpp 0
|
\snippet itemviews/addressbook/mainwindow.cpp 0
|
||||||
|
|
||||||
The \c createMenus() function sets up the \gui File and
|
The \c createMenus() function sets up the \uicontrol File and
|
||||||
\gui Tools menus, connecting the actions to their respective slots.
|
\uicontrol Tools menus, connecting the actions to their respective slots.
|
||||||
Both the \gui{Edit Entry...} and \gui{Remove Entry} actions are
|
Both the \uicontrol{Edit Entry...} and \uicontrol{Remove Entry} actions are
|
||||||
disabled by default as such actions cannot be carried out on an empty
|
disabled by default as such actions cannot be carried out on an empty
|
||||||
address book. They are only enabled when one or more contacts
|
address book. They are only enabled when one or more contacts
|
||||||
are added.
|
are added.
|
||||||
@ -413,18 +413,18 @@
|
|||||||
the \l{QFileDialog::getOpenFileName()}{open file dialog}. The chosen
|
the \l{QFileDialog::getOpenFileName()}{open file dialog}. The chosen
|
||||||
file has to be a custom \c{.dat} file that contains address book
|
file has to be a custom \c{.dat} file that contains address book
|
||||||
contacts. This function is a slot connected to \c openAct in the
|
contacts. This function is a slot connected to \c openAct in the
|
||||||
\gui File menu.
|
\uicontrol File menu.
|
||||||
|
|
||||||
\snippet itemviews/addressbook/mainwindow.cpp 2
|
\snippet itemviews/addressbook/mainwindow.cpp 2
|
||||||
|
|
||||||
The \c saveFile() function allows the user to save a file with
|
The \c saveFile() function allows the user to save a file with
|
||||||
the \l{QFileDialog::getSaveFileName()}{save file dialog}. This function
|
the \l{QFileDialog::getSaveFileName()}{save file dialog}. This function
|
||||||
is a slot connected to \c saveAct in the \gui File menu.
|
is a slot connected to \c saveAct in the \uicontrol File menu.
|
||||||
|
|
||||||
\snippet itemviews/addressbook/mainwindow.cpp 3
|
\snippet itemviews/addressbook/mainwindow.cpp 3
|
||||||
|
|
||||||
The \c updateActions() function enables and disables
|
The \c updateActions() function enables and disables
|
||||||
\gui{Edit Entry...} and \gui{Remove Entry} depending on the contents of
|
\uicontrol{Edit Entry...} and \uicontrol{Remove Entry} depending on the contents of
|
||||||
the address book. If the address book is empty, these actions
|
the address book. If the address book is empty, these actions
|
||||||
are disabled; otherwise, they are enabled. This function is a slot
|
are disabled; otherwise, they are enabled. This function is a slot
|
||||||
is connected to the \c AddressWidget's \c selectionChanged()
|
is connected to the \c AddressWidget's \c selectionChanged()
|
||||||
|
@ -41,8 +41,8 @@
|
|||||||
\list
|
\list
|
||||||
\li Dragging the red circle in the centre of each drawing moves it to a new position.
|
\li Dragging the red circle in the centre of each drawing moves it to a new position.
|
||||||
\li Dragging the displaced red circle causes the current drawing to be rotated about the
|
\li Dragging the displaced red circle causes the current drawing to be rotated about the
|
||||||
central circle. Rotation can also be controlled with the \key Rotate slider.
|
central circle. Rotation can also be controlled with the \uicontrol Rotate slider.
|
||||||
\li Scaling is controlled with the \key Scale slider.
|
\li Scaling is controlled with the \uicontrol Scale slider.
|
||||||
\li Each drawing can be sheared with the \key Shear slider.
|
\li Each drawing can be sheared with the \uicontrol Shear slider.
|
||||||
\endlist
|
\endlist
|
||||||
*/
|
*/
|
||||||
|
@ -152,7 +152,7 @@
|
|||||||
\snippet examples/mainwindows/application/mainwindow.cpp 12
|
\snippet examples/mainwindows/application/mainwindow.cpp 12
|
||||||
|
|
||||||
In \c saveAs(), we start by popping up a QFileDialog asking the
|
In \c saveAs(), we start by popping up a QFileDialog asking the
|
||||||
user to provide a name. If the user clicks \gui{Cancel}, the
|
user to provide a name. If the user clicks \uicontrol{Cancel}, the
|
||||||
returned file name is empty, and we do nothing.
|
returned file name is empty, and we do nothing.
|
||||||
|
|
||||||
\snippet examples/mainwindows/application/mainwindow.cpp 13
|
\snippet examples/mainwindows/application/mainwindow.cpp 13
|
||||||
@ -212,7 +212,7 @@
|
|||||||
\snippet examples/mainwindows/application/mainwindow.cpp 23
|
\snippet examples/mainwindows/application/mainwindow.cpp 23
|
||||||
\snippet examples/mainwindows/application/mainwindow.cpp 24
|
\snippet examples/mainwindows/application/mainwindow.cpp 24
|
||||||
|
|
||||||
The \gui{Edit|Cut} and \gui{Edit|Copy} actions must be available
|
The \uicontrol{Edit|Cut} and \uicontrol{Edit|Copy} actions must be available
|
||||||
only when the QPlainTextEdit contains selected text. We disable them
|
only when the QPlainTextEdit contains selected text. We disable them
|
||||||
by default and connect the QPlainTextEdit::copyAvailable() signal to
|
by default and connect the QPlainTextEdit::copyAvailable() signal to
|
||||||
the QAction::setEnabled() slot, ensuring that the actions are
|
the QAction::setEnabled() slot, ensuring that the actions are
|
||||||
@ -291,15 +291,15 @@
|
|||||||
The \c maybeSave() function is called to save pending changes. If
|
The \c maybeSave() function is called to save pending changes. If
|
||||||
there are pending changes, it pops up a QMessageBox giving the
|
there are pending changes, it pops up a QMessageBox giving the
|
||||||
user to save the document. The options are QMessageBox::Yes,
|
user to save the document. The options are QMessageBox::Yes,
|
||||||
QMessageBox::No, and QMessageBox::Cancel. The \gui{Yes} button is
|
QMessageBox::No, and QMessageBox::Cancel. The \uicontrol{Yes} button is
|
||||||
made the default button (the button that is invoked when the user
|
made the default button (the button that is invoked when the user
|
||||||
presses \key{Return}) using the QMessageBox::Default flag; the
|
presses \uicontrol{Return}) using the QMessageBox::Default flag; the
|
||||||
\gui{Cancel} button is made the escape button (the button that is
|
\uicontrol{Cancel} button is made the escape button (the button that is
|
||||||
invoked when the user presses \key{Esc}) using the
|
invoked when the user presses \uicontrol{Esc}) using the
|
||||||
QMessageBox::Escape flag.
|
QMessageBox::Escape flag.
|
||||||
|
|
||||||
The \c maybeSave() function returns \c true in all cases, except
|
The \c maybeSave() function returns \c true in all cases, except
|
||||||
when the user clicks \gui{Cancel}. The caller must check the
|
when the user clicks \uicontrol{Cancel}. The caller must check the
|
||||||
return value and stop whatever it was doing if the return value
|
return value and stop whatever it was doing if the return value
|
||||||
is \c false.
|
is \c false.
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@
|
|||||||
languages. "Ctrl+Q" is a good choice for Quit in English, but a
|
languages. "Ctrl+Q" is a good choice for Quit in English, but a
|
||||||
Dutch translator might want to use "Ctrl+A" (for Afsluiten) and a
|
Dutch translator might want to use "Ctrl+A" (for Afsluiten) and a
|
||||||
German translator "Strg+E" (for Beenden). When using \c tr() for
|
German translator "Strg+E" (for Beenden). When using \c tr() for
|
||||||
\key Ctrl key accelerators, the two argument form should be used
|
\uicontrol Ctrl key accelerators, the two argument form should be used
|
||||||
with the second argument describing the function that the
|
with the second argument describing the function that the
|
||||||
accelerator performs.
|
accelerator performs.
|
||||||
|
|
||||||
@ -157,7 +157,7 @@
|
|||||||
\endlist
|
\endlist
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
It's quickest to press \key{Alt+D} (which clicks the \gui {Done \& Next}
|
It's quickest to press \uicontrol{Alt+D} (which clicks the \uicontrol {Done \& Next}
|
||||||
button) after typing each translation, since this marks the
|
button) after typing each translation, since this marks the
|
||||||
translation as done and moves on to the next source text.
|
translation as done and moves on to the next source text.
|
||||||
|
|
||||||
@ -183,7 +183,7 @@
|
|||||||
files into QM files. We could use \e {Qt Linguist} as we've done
|
files into QM files. We could use \e {Qt Linguist} as we've done
|
||||||
before; however using the command line tool \c lrelease ensures that
|
before; however using the command line tool \c lrelease ensures that
|
||||||
\e all the QM files for the application are created without us
|
\e all the QM files for the application are created without us
|
||||||
having to remember to load and \gui File|Release each one
|
having to remember to load and \uicontrol File|Release each one
|
||||||
individually from \e {Qt Linguist}.
|
individually from \e {Qt Linguist}.
|
||||||
|
|
||||||
Type
|
Type
|
||||||
|
@ -43,10 +43,10 @@
|
|||||||
The example provides a render area, displaying the currently
|
The example provides a render area, displaying the currently
|
||||||
active shape, and lets the user manipulate the rendered shape and
|
active shape, and lets the user manipulate the rendered shape and
|
||||||
its appearance using the QPainter parameters: The user can change
|
its appearance using the QPainter parameters: The user can change
|
||||||
the active shape (\gui Shape), and modify the QPainter's pen (\gui
|
the active shape (\uicontrol Shape), and modify the QPainter's pen (\uicontrol
|
||||||
{Pen Width}, \gui {Pen Style}, \gui {Pen Cap}, \gui {Pen Join}),
|
{Pen Width}, \uicontrol {Pen Style}, \uicontrol {Pen Cap}, \uicontrol {Pen Join}),
|
||||||
brush (\gui {Brush Style}) and render hints (\gui
|
brush (\uicontrol {Brush Style}) and render hints (\uicontrol
|
||||||
Antialiasing). In addition the user can rotate a shape (\gui
|
Antialiasing). In addition the user can rotate a shape (\uicontrol
|
||||||
Transformations); behind the scenes we use QPainter's ability to
|
Transformations); behind the scenes we use QPainter's ability to
|
||||||
manipulate the coordinate system to perform the rotation.
|
manipulate the coordinate system to perform the rotation.
|
||||||
|
|
||||||
@ -86,7 +86,7 @@
|
|||||||
\snippet examples/painting/basicdrawing/window.cpp 1
|
\snippet examples/painting/basicdrawing/window.cpp 1
|
||||||
|
|
||||||
First we create the \c RenderArea widget that will render the
|
First we create the \c RenderArea widget that will render the
|
||||||
currently active shape. Then we create the \gui Shape combobox,
|
currently active shape. Then we create the \uicontrol Shape combobox,
|
||||||
and add the associated items (i.e. the different shapes a QPainter
|
and add the associated items (i.e. the different shapes a QPainter
|
||||||
can draw).
|
can draw).
|
||||||
|
|
||||||
@ -101,7 +101,7 @@
|
|||||||
the shape is drawn as smoothly as possible although perhaps not
|
the shape is drawn as smoothly as possible although perhaps not
|
||||||
mathematically correct.
|
mathematically correct.
|
||||||
|
|
||||||
We create a QSpinBox for the \gui {Pen Width} parameter.
|
We create a QSpinBox for the \uicontrol {Pen Width} parameter.
|
||||||
|
|
||||||
\snippet examples/painting/basicdrawing/window.cpp 3
|
\snippet examples/painting/basicdrawing/window.cpp 3
|
||||||
|
|
||||||
@ -112,8 +112,8 @@
|
|||||||
two lines join when multiple connected lines are drawn. The cap
|
two lines join when multiple connected lines are drawn. The cap
|
||||||
and join only apply to lines with a width of 1 pixel or greater.
|
and join only apply to lines with a width of 1 pixel or greater.
|
||||||
|
|
||||||
We create \l {QComboBox}es for each of the \gui {Pen Style}, \gui
|
We create \l {QComboBox}es for each of the \uicontrol {Pen Style}, \uicontrol
|
||||||
{Pen Cap} and \gui {Pen Join} parameters, and adds the associated
|
{Pen Cap} and \uicontrol {Pen Join} parameters, and adds the associated
|
||||||
items (i.e the values of the Qt::PenStyle, Qt::PenCapStyle and
|
items (i.e the values of the Qt::PenStyle, Qt::PenCapStyle and
|
||||||
Qt::PenJoinStyle enums respectively).
|
Qt::PenJoinStyle enums respectively).
|
||||||
|
|
||||||
@ -124,7 +124,7 @@
|
|||||||
the painter to not fill shapes. The standard style for filling is
|
the painter to not fill shapes. The standard style for filling is
|
||||||
Qt::SolidPattern.
|
Qt::SolidPattern.
|
||||||
|
|
||||||
We create a QComboBox for the \gui {Brush Style} parameter, and add
|
We create a QComboBox for the \uicontrol {Brush Style} parameter, and add
|
||||||
the associated items (i.e. the values of the Qt::BrushStyle enum).
|
the associated items (i.e. the values of the Qt::BrushStyle enum).
|
||||||
|
|
||||||
\snippet examples/painting/basicdrawing/window.cpp 5
|
\snippet examples/painting/basicdrawing/window.cpp 5
|
||||||
@ -136,11 +136,11 @@
|
|||||||
flags to QPainter that may or may not be respected by any given
|
flags to QPainter that may or may not be respected by any given
|
||||||
engine.
|
engine.
|
||||||
|
|
||||||
We simply create a QCheckBox for the \gui Antialiasing option.
|
We simply create a QCheckBox for the \uicontrol Antialiasing option.
|
||||||
|
|
||||||
\snippet examples/painting/basicdrawing/window.cpp 7
|
\snippet examples/painting/basicdrawing/window.cpp 7
|
||||||
|
|
||||||
The \gui Transformations option implies a manipulation of the
|
The \uicontrol Transformations option implies a manipulation of the
|
||||||
coordinate system that will appear as if the rendered shape is
|
coordinate system that will appear as if the rendered shape is
|
||||||
rotated in three dimensions.
|
rotated in three dimensions.
|
||||||
|
|
||||||
@ -289,7 +289,7 @@
|
|||||||
|
|
||||||
\snippet examples/painting/basicdrawing/renderarea.cpp 0
|
\snippet examples/painting/basicdrawing/renderarea.cpp 0
|
||||||
|
|
||||||
We set its shape to be a \gui Polygon, its antialiased property to
|
We set its shape to be a \uicontrol Polygon, its antialiased property to
|
||||||
be false and we load an image into the widget's pixmap
|
be false and we load an image into the widget's pixmap
|
||||||
variable. In the end we set the widget's background role, defining
|
variable. In the end we set the widget's background role, defining
|
||||||
the brush from the widget's \l {QWidget::palette}{palette} that
|
the brush from the widget's \l {QWidget::palette}{palette} that
|
||||||
@ -356,10 +356,10 @@
|
|||||||
draw the various shapes.
|
draw the various shapes.
|
||||||
|
|
||||||
We create a vector of four \l {QPoint}s. We use this vector to
|
We create a vector of four \l {QPoint}s. We use this vector to
|
||||||
render the \gui Points, \gui Polyline and \gui Polygon
|
render the \uicontrol Points, \uicontrol Polyline and \uicontrol Polygon
|
||||||
shapes. Then we create a QRect, defining a rectangle in the plane,
|
shapes. Then we create a QRect, defining a rectangle in the plane,
|
||||||
which we use as the bounding rectangle for all the shapes excluding
|
which we use as the bounding rectangle for all the shapes excluding
|
||||||
the \gui Path and the \gui Pixmap.
|
the \uicontrol Path and the \uicontrol Pixmap.
|
||||||
|
|
||||||
We also create a QPainterPath. The QPainterPath class provides a
|
We also create a QPainterPath. The QPainterPath class provides a
|
||||||
container for painting operations, enabling graphical shapes to be
|
container for painting operations, enabling graphical shapes to be
|
||||||
@ -371,13 +371,13 @@
|
|||||||
straight line and a Bezier curve.
|
straight line and a Bezier curve.
|
||||||
|
|
||||||
In addition we define a start angle and an arc length that we will
|
In addition we define a start angle and an arc length that we will
|
||||||
use when drawing the \gui Arc, \gui Chord and \gui Pie shapes.
|
use when drawing the \uicontrol Arc, \uicontrol Chord and \uicontrol Pie shapes.
|
||||||
|
|
||||||
\snippet examples/painting/basicdrawing/renderarea.cpp 9
|
\snippet examples/painting/basicdrawing/renderarea.cpp 9
|
||||||
|
|
||||||
We create a QPainter for the \c RenderArea widget, and set the
|
We create a QPainter for the \c RenderArea widget, and set the
|
||||||
painters pen and brush according to the \c RenderArea's pen and
|
painters pen and brush according to the \c RenderArea's pen and
|
||||||
brush. If the \gui Antialiasing parameter option is checked, we
|
brush. If the \uicontrol Antialiasing parameter option is checked, we
|
||||||
also set the painter's render hints. QPainter::Antialiasing
|
also set the painter's render hints. QPainter::Antialiasing
|
||||||
indicates that the engine should antialias edges of primitives if
|
indicates that the engine should antialias edges of primitives if
|
||||||
possible.
|
possible.
|
||||||
@ -399,7 +399,7 @@
|
|||||||
|
|
||||||
\snippet examples/painting/basicdrawing/renderarea.cpp 11
|
\snippet examples/painting/basicdrawing/renderarea.cpp 11
|
||||||
|
|
||||||
If the \gui Transformations parameter option is checked, we do an
|
If the \uicontrol Transformations parameter option is checked, we do an
|
||||||
additional translation of the coordinate system before we rotate
|
additional translation of the coordinate system before we rotate
|
||||||
the coordinate system 60 degrees clockwise using the
|
the coordinate system 60 degrees clockwise using the
|
||||||
QPainter::rotate() function and scale it down in size using the
|
QPainter::rotate() function and scale it down in size using the
|
||||||
@ -448,7 +448,7 @@
|
|||||||
We could translate the coordinate system back using
|
We could translate the coordinate system back using
|
||||||
QPainter::translate() instead of saving the painter state. But
|
QPainter::translate() instead of saving the painter state. But
|
||||||
since we in addition to translating the coordinate system (when
|
since we in addition to translating the coordinate system (when
|
||||||
the \gui Transformation parameter option is checked) both rotate
|
the \uicontrol Transformation parameter option is checked) both rotate
|
||||||
and scale the coordinate system, the easiest solution is to save
|
and scale the coordinate system, the easiest solution is to save
|
||||||
the current painter state.
|
the current painter state.
|
||||||
*/
|
*/
|
||||||
|
@ -122,7 +122,7 @@
|
|||||||
\snippet examples/layouts/basiclayouts/dialog.cpp 6
|
\snippet examples/layouts/basiclayouts/dialog.cpp 6
|
||||||
|
|
||||||
In the private \c createMenu() function we create a menu bar, and
|
In the private \c createMenu() function we create a menu bar, and
|
||||||
add a pull-down \gui File menu containing an \gui Exit option.
|
add a pull-down \uicontrol File menu containing an \uicontrol Exit option.
|
||||||
|
|
||||||
\snippet examples/layouts/basiclayouts/dialog.cpp 7
|
\snippet examples/layouts/basiclayouts/dialog.cpp 7
|
||||||
|
|
||||||
|
@ -146,16 +146,16 @@
|
|||||||
{QDialogButtonBox}{addButton()} function, the button's role must
|
{QDialogButtonBox}{addButton()} function, the button's role must
|
||||||
be specified using the QDialogButtonBox::ButtonRole
|
be specified using the QDialogButtonBox::ButtonRole
|
||||||
enum. Alternatively, QDialogButtonBox provides several standard
|
enum. Alternatively, QDialogButtonBox provides several standard
|
||||||
buttons (e.g. \gui OK, \gui Cancel, \gui Save) that you can
|
buttons (e.g. \uicontrol OK, \uicontrol Cancel, \uicontrol Save) that you can
|
||||||
use. They exist as flags so you can OR them together in the
|
use. They exist as flags so you can OR them together in the
|
||||||
constructor.
|
constructor.
|
||||||
|
|
||||||
\snippet examples/sql/cachedtable/tableeditor.cpp 3
|
\snippet examples/sql/cachedtable/tableeditor.cpp 3
|
||||||
|
|
||||||
We connect the \gui Quit button to the table editor's \l
|
We connect the \uicontrol Quit button to the table editor's \l
|
||||||
{QWidget::close()}{close()} slot, and the \gui Submit button to
|
{QWidget::close()}{close()} slot, and the \uicontrol Submit button to
|
||||||
our private \c submit() slot. The latter slot will take care of
|
our private \c submit() slot. The latter slot will take care of
|
||||||
the data transactions. Finally, we connect the \gui Revert button
|
the data transactions. Finally, we connect the \uicontrol Revert button
|
||||||
to our model's \l {QSqlTableModel::revertAll()}{revertAll()} slot,
|
to our model's \l {QSqlTableModel::revertAll()}{revertAll()} slot,
|
||||||
reverting all pending changes (i.e., restoring the original data).
|
reverting all pending changes (i.e., restoring the original data).
|
||||||
|
|
||||||
@ -167,7 +167,7 @@
|
|||||||
|
|
||||||
\snippet examples/sql/cachedtable/tableeditor.cpp 5
|
\snippet examples/sql/cachedtable/tableeditor.cpp 5
|
||||||
|
|
||||||
The \c submit() slot is called whenever the users hit the \gui
|
The \c submit() slot is called whenever the users hit the \uicontrol
|
||||||
Submit button to save their changes.
|
Submit button to save their changes.
|
||||||
|
|
||||||
First, we begin a transaction on the database using the
|
First, we begin a transaction on the database using the
|
||||||
|
@ -57,12 +57,12 @@
|
|||||||
reimplemented to handle mouse events on the calculator's display.
|
reimplemented to handle mouse events on the calculator's display.
|
||||||
|
|
||||||
Buttons are grouped in categories according to their behavior.
|
Buttons are grouped in categories according to their behavior.
|
||||||
For example, all the digit buttons (labeled \gui 0 to \gui 9)
|
For example, all the digit buttons (labeled \uicontrol 0 to \uicontrol 9)
|
||||||
append a digit to the current operand. For these, we connect
|
append a digit to the current operand. For these, we connect
|
||||||
multiple buttons to the same slot (e.g., \c digitClicked()). The
|
multiple buttons to the same slot (e.g., \c digitClicked()). The
|
||||||
categories are digits, unary operators (\gui{Sqrt}, \gui{x\unicode{178}},
|
categories are digits, unary operators (\uicontrol{Sqrt}, \uicontrol{x\unicode{178}},
|
||||||
\gui{1/x}), additive operators (\gui{+}, \gui{-}), and
|
\uicontrol{1/x}), additive operators (\uicontrol{+}, \uicontrol{-}), and
|
||||||
multiplicative operators (\gui{\unicode{215}}, \gui{\unicode{247}}). The other buttons
|
multiplicative operators (\uicontrol{\unicode{215}}, \uicontrol{\unicode{247}}). The other buttons
|
||||||
have their own slots.
|
have their own slots.
|
||||||
|
|
||||||
\snippet examples/widgets/calculator/calculator.h 1
|
\snippet examples/widgets/calculator/calculator.h 1
|
||||||
@ -72,7 +72,7 @@
|
|||||||
widget construction. \c abortOperation() is called whenever a
|
widget construction. \c abortOperation() is called whenever a
|
||||||
division by zero occurs or when a square root operation is
|
division by zero occurs or when a square root operation is
|
||||||
applied to a negative number. \c calculate() applies a binary
|
applied to a negative number. \c calculate() applies a binary
|
||||||
operator (\gui{+}, \gui{-}, \gui{\unicode{215}}, or \gui{\unicode{247}}).
|
operator (\uicontrol{+}, \uicontrol{-}, \uicontrol{\unicode{215}}, or \uicontrol{\unicode{247}}).
|
||||||
|
|
||||||
\snippet examples/widgets/calculator/calculator.h 3
|
\snippet examples/widgets/calculator/calculator.h 3
|
||||||
\snippet examples/widgets/calculator/calculator.h 4
|
\snippet examples/widgets/calculator/calculator.h 4
|
||||||
@ -86,10 +86,10 @@
|
|||||||
|
|
||||||
\list
|
\list
|
||||||
\li \c sumInMemory contains the value stored in the calculator's memory
|
\li \c sumInMemory contains the value stored in the calculator's memory
|
||||||
(using \gui{MS}, \gui{M+}, or \gui{MC}).
|
(using \uicontrol{MS}, \uicontrol{M+}, or \uicontrol{MC}).
|
||||||
\li \c sumSoFar stores the value accumulated so far. When the user
|
\li \c sumSoFar stores the value accumulated so far. When the user
|
||||||
clicks \gui{=}, \c sumSoFar is recomputed and shown on the
|
clicks \uicontrol{=}, \c sumSoFar is recomputed and shown on the
|
||||||
display. \gui{Clear All} resets \c sumSoFar to zero.
|
display. \uicontrol{Clear All} resets \c sumSoFar to zero.
|
||||||
\li \c factorSoFar stores a temporary value when doing
|
\li \c factorSoFar stores a temporary value when doing
|
||||||
multiplications and divisions.
|
multiplications and divisions.
|
||||||
\li \c pendingAdditiveOperator stores the last additive operator
|
\li \c pendingAdditiveOperator stores the last additive operator
|
||||||
@ -101,9 +101,9 @@
|
|||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
Additive and multiplicative operators are treated differently
|
Additive and multiplicative operators are treated differently
|
||||||
because they have different precedences. For example, \gui{1 + 2 \unicode{247}
|
because they have different precedences. For example, \uicontrol{1 + 2 \unicode{247}
|
||||||
3} is interpreted as \gui{1 + (2 \unicode{247} 3)} because \gui{\unicode{247}} has higher
|
3} is interpreted as \uicontrol{1 + (2 \unicode{247} 3)} because \uicontrol{\unicode{247}} has higher
|
||||||
precedence than \gui{+}.
|
precedence than \uicontrol{+}.
|
||||||
|
|
||||||
The table below shows the evolution of the calculator state as
|
The table below shows the evolution of the calculator state as
|
||||||
the user enters a mathematical expression.
|
the user enters a mathematical expression.
|
||||||
@ -111,17 +111,17 @@
|
|||||||
\table
|
\table
|
||||||
\header \li User Input \li Display \li Sum so Far \li Add. Op. \li Factor so Far \li Mult. Op. \li Waiting for Operand?
|
\header \li User Input \li Display \li Sum so Far \li Add. Op. \li Factor so Far \li Mult. Op. \li Waiting for Operand?
|
||||||
\row \li \li 0 \li 0 \li \li \li \li \c true
|
\row \li \li 0 \li 0 \li \li \li \li \c true
|
||||||
\row \li \gui{1} \li 1 \li 0 \li \li \li \li \c false
|
\row \li \uicontrol{1} \li 1 \li 0 \li \li \li \li \c false
|
||||||
\row \li \gui{1 +} \li 1 \li 1 \li \gui{+} \li \li \li \c true
|
\row \li \uicontrol{1 +} \li 1 \li 1 \li \uicontrol{+} \li \li \li \c true
|
||||||
\row \li \gui{1 + 2} \li 2 \li 1 \li \gui{+} \li \li \li \c false
|
\row \li \uicontrol{1 + 2} \li 2 \li 1 \li \uicontrol{+} \li \li \li \c false
|
||||||
\row \li \gui{1 + 2 \unicode{247}} \li 2 \li 1 \li \gui{+} \li 2 \li \gui{\unicode{247}} \li \c true
|
\row \li \uicontrol{1 + 2 \unicode{247}} \li 2 \li 1 \li \uicontrol{+} \li 2 \li \uicontrol{\unicode{247}} \li \c true
|
||||||
\row \li \gui{1 + 2 \unicode{247} 3} \li 3 \li 1 \li \gui{+} \li 2 \li \gui{\unicode{247}} \li \c false
|
\row \li \uicontrol{1 + 2 \unicode{247} 3} \li 3 \li 1 \li \uicontrol{+} \li 2 \li \uicontrol{\unicode{247}} \li \c false
|
||||||
\row \li \gui{1 + 2 \unicode{247} 3 -} \li 1.66667 \li 1.66667 \li \gui{-} \li \li \li \c true
|
\row \li \uicontrol{1 + 2 \unicode{247} 3 -} \li 1.66667 \li 1.66667 \li \uicontrol{-} \li \li \li \c true
|
||||||
\row \li \gui{1 + 2 \unicode{247} 3 - 4} \li 4 \li 1.66667 \li \gui{-} \li \li \li \c false
|
\row \li \uicontrol{1 + 2 \unicode{247} 3 - 4} \li 4 \li 1.66667 \li \uicontrol{-} \li \li \li \c false
|
||||||
\row \li \gui{1 + 2 \unicode{247} 3 - 4 =} \li -2.33333 \li 0 \li \li \li \li \c true
|
\row \li \uicontrol{1 + 2 \unicode{247} 3 - 4 =} \li -2.33333 \li 0 \li \li \li \li \c true
|
||||||
\endtable
|
\endtable
|
||||||
|
|
||||||
Unary operators, such as \gui Sqrt, require no special handling;
|
Unary operators, such as \uicontrol Sqrt, require no special handling;
|
||||||
they can be applied immediately since the operand is already
|
they can be applied immediately since the operand is already
|
||||||
known when the operator button is clicked.
|
known when the operator button is clicked.
|
||||||
|
|
||||||
@ -190,7 +190,7 @@
|
|||||||
the operator using QToolButton::text().
|
the operator using QToolButton::text().
|
||||||
|
|
||||||
The slot needs to consider two situations in particular. If \c
|
The slot needs to consider two situations in particular. If \c
|
||||||
display contains "0" and the user clicks the \gui{0} button, it
|
display contains "0" and the user clicks the \uicontrol{0} button, it
|
||||||
would be silly to show "00". And if the calculator is in
|
would be silly to show "00". And if the calculator is in
|
||||||
a state where it is waiting for a new operand,
|
a state where it is waiting for a new operand,
|
||||||
the new digit is the first digit of that new operand; in that case,
|
the new digit is the first digit of that new operand; in that case,
|
||||||
@ -207,8 +207,8 @@
|
|||||||
extracted from the button's text and stored in \c
|
extracted from the button's text and stored in \c
|
||||||
clickedOperator. The operand is obtained from \c display.
|
clickedOperator. The operand is obtained from \c display.
|
||||||
|
|
||||||
Then we perform the operation. If \gui Sqrt is applied to a
|
Then we perform the operation. If \uicontrol Sqrt is applied to a
|
||||||
negative number or \gui{1/x} to zero, we call \c
|
negative number or \uicontrol{1/x} to zero, we call \c
|
||||||
abortOperation(). If everything goes well, we display the result
|
abortOperation(). If everything goes well, we display the result
|
||||||
of the operation in the line edit and we set \c waitingForOperand
|
of the operation in the line edit and we set \c waitingForOperand
|
||||||
to \c true. This ensures that if the user types a new digit, the
|
to \c true. This ensures that if the user types a new digit, the
|
||||||
@ -219,7 +219,7 @@
|
|||||||
\snippet examples/widgets/calculator/calculator.cpp 11
|
\snippet examples/widgets/calculator/calculator.cpp 11
|
||||||
|
|
||||||
The \c additiveOperatorClicked() slot is called when the user
|
The \c additiveOperatorClicked() slot is called when the user
|
||||||
clicks the \gui{+} or \gui{-} button.
|
clicks the \uicontrol{+} or \uicontrol{-} button.
|
||||||
|
|
||||||
Before we can actually do something about the clicked operator,
|
Before we can actually do something about the clicked operator,
|
||||||
we must handle any pending operations. We start with the
|
we must handle any pending operations. We start with the
|
||||||
@ -229,15 +229,15 @@
|
|||||||
\snippet examples/widgets/calculator/calculator.cpp 12
|
\snippet examples/widgets/calculator/calculator.cpp 12
|
||||||
\snippet examples/widgets/calculator/calculator.cpp 13
|
\snippet examples/widgets/calculator/calculator.cpp 13
|
||||||
|
|
||||||
If \gui{\unicode{215}} or \gui{\unicode{247}} has been clicked earlier, without clicking
|
If \uicontrol{\unicode{215}} or \uicontrol{\unicode{247}} has been clicked earlier, without clicking
|
||||||
\gui{=} afterward, the current value in the display is the right
|
\uicontrol{=} afterward, the current value in the display is the right
|
||||||
operand of the \gui{\unicode{215}} or \gui{\unicode{247}} operator and we can finally
|
operand of the \uicontrol{\unicode{215}} or \uicontrol{\unicode{247}} operator and we can finally
|
||||||
perform the operation and update the display.
|
perform the operation and update the display.
|
||||||
|
|
||||||
\snippet examples/widgets/calculator/calculator.cpp 14
|
\snippet examples/widgets/calculator/calculator.cpp 14
|
||||||
\snippet examples/widgets/calculator/calculator.cpp 15
|
\snippet examples/widgets/calculator/calculator.cpp 15
|
||||||
|
|
||||||
If \gui{+} or \gui{-} has been clicked earlier, \c sumSoFar is
|
If \uicontrol{+} or \uicontrol{-} has been clicked earlier, \c sumSoFar is
|
||||||
the left operand and the current value in the display is the
|
the left operand and the current value in the display is the
|
||||||
right operand of the operator. If there is no pending additive
|
right operand of the operator. If there is no pending additive
|
||||||
operator, \c sumSoFar is simply set to be the text in the
|
operator, \c sumSoFar is simply set to be the text in the
|
||||||
@ -287,7 +287,7 @@
|
|||||||
\snippet examples/widgets/calculator/calculator.cpp 28
|
\snippet examples/widgets/calculator/calculator.cpp 28
|
||||||
|
|
||||||
The \c clear() slot resets the current operand to zero. It is
|
The \c clear() slot resets the current operand to zero. It is
|
||||||
equivalent to clicking \gui Backspace enough times to erase the
|
equivalent to clicking \uicontrol Backspace enough times to erase the
|
||||||
entire operand.
|
entire operand.
|
||||||
|
|
||||||
\snippet examples/widgets/calculator/calculator.cpp 30
|
\snippet examples/widgets/calculator/calculator.cpp 30
|
||||||
@ -363,7 +363,7 @@
|
|||||||
|
|
||||||
This ensures that with most fonts, the digit and operator buttons
|
This ensures that with most fonts, the digit and operator buttons
|
||||||
will be square, without truncating the text on the
|
will be square, without truncating the text on the
|
||||||
\gui{Backspace}, \gui{Clear}, and \gui{Clear All} buttons.
|
\uicontrol{Backspace}, \uicontrol{Clear}, and \uicontrol{Clear All} buttons.
|
||||||
|
|
||||||
The screenshot below shows how the \c Calculator widget would
|
The screenshot below shows how the \c Calculator widget would
|
||||||
look like if we \e didn't set the horizontal size policy to
|
look like if we \e didn't set the horizontal size policy to
|
||||||
|
@ -118,7 +118,7 @@
|
|||||||
|
|
||||||
\snippet examples/widgets/calendarwidget/window.cpp 9
|
\snippet examples/widgets/calendarwidget/window.cpp 9
|
||||||
|
|
||||||
The \gui Preview group box contains only one widget: the
|
The \uicontrol Preview group box contains only one widget: the
|
||||||
QCalendarWidget. We set it up, connect its
|
QCalendarWidget. We set it up, connect its
|
||||||
\l{QCalendarWidget::}{currentPageChanged()} signal to our \c
|
\l{QCalendarWidget::}{currentPageChanged()} signal to our \c
|
||||||
reformatCalendarPage() slot to make sure that every new page gets
|
reformatCalendarPage() slot to make sure that every new page gets
|
||||||
@ -131,7 +131,7 @@
|
|||||||
\snippet examples/widgets/calendarwidget/window.cpp 10
|
\snippet examples/widgets/calendarwidget/window.cpp 10
|
||||||
\dots
|
\dots
|
||||||
|
|
||||||
We start with the setup of the \gui{Week starts on} combobox.
|
We start with the setup of the \uicontrol{Week starts on} combobox.
|
||||||
This combobox controls which day should be displayed as the first
|
This combobox controls which day should be displayed as the first
|
||||||
day of the week.
|
day of the week.
|
||||||
|
|
||||||
@ -159,8 +159,8 @@
|
|||||||
|
|
||||||
\snippet examples/widgets/calendarwidget/window.cpp 13
|
\snippet examples/widgets/calendarwidget/window.cpp 13
|
||||||
|
|
||||||
In this function, we create the \gui {Minimum Date}, \gui {Maximum Date},
|
In this function, we create the \uicontrol {Minimum Date}, \uicontrol {Maximum Date},
|
||||||
and \gui {Current Date} editor widgets,
|
and \uicontrol {Current Date} editor widgets,
|
||||||
which control the calendar's minimum, maximum, and selected dates.
|
which control the calendar's minimum, maximum, and selected dates.
|
||||||
The calendar's minimum and maximum dates have already been
|
The calendar's minimum and maximum dates have already been
|
||||||
set in \c createPrivewGroupBox(); we can then set the widgets
|
set in \c createPrivewGroupBox(); we can then set the widgets
|
||||||
@ -175,28 +175,28 @@
|
|||||||
\l{QCalendarWidget::}{setSelectedDate()} slot. When the calendar's
|
\l{QCalendarWidget::}{setSelectedDate()} slot. When the calendar's
|
||||||
selected date changes, either as a result of a user action or
|
selected date changes, either as a result of a user action or
|
||||||
programmatically, our \c selectedDateChanged() slot updates
|
programmatically, our \c selectedDateChanged() slot updates
|
||||||
the \gui {Current Date} editor. We also need to react when the user
|
the \uicontrol {Current Date} editor. We also need to react when the user
|
||||||
changes the \gui{Minimum Date} and \gui{Maximum Date} editors.
|
changes the \uicontrol{Minimum Date} and \uicontrol{Maximum Date} editors.
|
||||||
|
|
||||||
Here is the \c createTextFormatsGroup() function:
|
Here is the \c createTextFormatsGroup() function:
|
||||||
|
|
||||||
\snippet examples/widgets/calendarwidget/window.cpp 16
|
\snippet examples/widgets/calendarwidget/window.cpp 16
|
||||||
|
|
||||||
We set up the \gui {Weekday Color} and \gui {Weekend Color} comboboxes
|
We set up the \uicontrol {Weekday Color} and \uicontrol {Weekend Color} comboboxes
|
||||||
using \c createColorCombo(), which instantiates a QComboBox and
|
using \c createColorCombo(), which instantiates a QComboBox and
|
||||||
populates it with colors ("Red", "Blue", etc.).
|
populates it with colors ("Red", "Blue", etc.).
|
||||||
|
|
||||||
\snippet examples/widgets/calendarwidget/window.cpp 17
|
\snippet examples/widgets/calendarwidget/window.cpp 17
|
||||||
|
|
||||||
The \gui {Header Text Format} combobox lets the user change the
|
The \uicontrol {Header Text Format} combobox lets the user change the
|
||||||
text format (bold, italic, or plain) used for horizontal and
|
text format (bold, italic, or plain) used for horizontal and
|
||||||
vertical headers. The \gui {First Friday in blue} and \gui {May 1
|
vertical headers. The \uicontrol {First Friday in blue} and \uicontrol {May 1
|
||||||
in red} check box affect the rendering of specific dates.
|
in red} check box affect the rendering of specific dates.
|
||||||
|
|
||||||
\snippet examples/widgets/calendarwidget/window.cpp 18
|
\snippet examples/widgets/calendarwidget/window.cpp 18
|
||||||
|
|
||||||
We connect the check boxes and comboboxes to various private
|
We connect the check boxes and comboboxes to various private
|
||||||
slots. The \gui {First Friday in blue} and \gui {May 1 in red}
|
slots. The \uicontrol {First Friday in blue} and \uicontrol {May 1 in red}
|
||||||
check boxes are both connected to \c reformatCalendarPage(),
|
check boxes are both connected to \c reformatCalendarPage(),
|
||||||
which is also called when the calendar switches month.
|
which is also called when the calendar switches month.
|
||||||
|
|
||||||
@ -216,12 +216,12 @@
|
|||||||
standard colors. The second argument to QComboBox::addItem()
|
standard colors. The second argument to QComboBox::addItem()
|
||||||
is a QVariant storing user data (in this case, QColor objects).
|
is a QVariant storing user data (in this case, QColor objects).
|
||||||
|
|
||||||
This function was used to set up the \gui {Weekday Color}
|
This function was used to set up the \uicontrol {Weekday Color}
|
||||||
and \gui {Weekend Color} comboboxes.
|
and \uicontrol {Weekend Color} comboboxes.
|
||||||
|
|
||||||
\snippet examples/widgets/calendarwidget/window.cpp 1
|
\snippet examples/widgets/calendarwidget/window.cpp 1
|
||||||
|
|
||||||
When the user changes the \gui {Week starts on} combobox's
|
When the user changes the \uicontrol {Week starts on} combobox's
|
||||||
value, \c firstDayChanged() is invoked with the index of the
|
value, \c firstDayChanged() is invoked with the index of the
|
||||||
combobox's new value. We retrieve the custom data item
|
combobox's new value. We retrieve the custom data item
|
||||||
associated with the new current item using
|
associated with the new current item using
|
||||||
@ -233,13 +233,13 @@
|
|||||||
|
|
||||||
\snippet examples/widgets/calendarwidget/window.cpp 2
|
\snippet examples/widgets/calendarwidget/window.cpp 2
|
||||||
|
|
||||||
The \c selectedDateChanged() updates the \gui{Current Date}
|
The \c selectedDateChanged() updates the \uicontrol{Current Date}
|
||||||
editor to reflect the current state of the QCalendarWidget.
|
editor to reflect the current state of the QCalendarWidget.
|
||||||
|
|
||||||
\snippet examples/widgets/calendarwidget/window.cpp 3
|
\snippet examples/widgets/calendarwidget/window.cpp 3
|
||||||
|
|
||||||
When the user changes the minimum date, we tell the
|
When the user changes the minimum date, we tell the
|
||||||
QCalenderWidget. We also update the \gui {Maximum Date} editor,
|
QCalenderWidget. We also update the \uicontrol {Maximum Date} editor,
|
||||||
because if the new minimum date is later than the current maximum
|
because if the new minimum date is later than the current maximum
|
||||||
date, QCalendarWidget will automatically adapt its maximum date
|
date, QCalendarWidget will automatically adapt its maximum date
|
||||||
to avoid a contradicting state.
|
to avoid a contradicting state.
|
||||||
@ -270,7 +270,7 @@
|
|||||||
|
|
||||||
The \c reformatHeaders() slot is called when the user
|
The \c reformatHeaders() slot is called when the user
|
||||||
changes the text format of
|
changes the text format of
|
||||||
the headers. We compare the current text of the \gui {Header Text Format}
|
the headers. We compare the current text of the \uicontrol {Header Text Format}
|
||||||
combobox to determine which format to apply. (An alternative would
|
combobox to determine which format to apply. (An alternative would
|
||||||
have been to store \l{QTextCharFormat} values alongside the combobox
|
have been to store \l{QTextCharFormat} values alongside the combobox
|
||||||
items.)
|
items.)
|
||||||
|
@ -74,8 +74,8 @@
|
|||||||
\li The fifth page is a conclusion page.
|
\li The fifth page is a conclusion page.
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
Although the program is just an example, if you press \gui Finish
|
Although the program is just an example, if you press \uicontrol Finish
|
||||||
(\gui Done on Mac OS X), actual C++ source files will actually be
|
(\uicontrol Done on Mac OS X), actual C++ source files will actually be
|
||||||
generated.
|
generated.
|
||||||
|
|
||||||
\section1 The ClassWizard Class
|
\section1 The ClassWizard Class
|
||||||
@ -85,7 +85,7 @@
|
|||||||
\snippet examples/dialogs/classwizard/classwizard.h 0
|
\snippet examples/dialogs/classwizard/classwizard.h 0
|
||||||
|
|
||||||
The class reimplements QDialog's \l{QDialog::}{accept()} slot.
|
The class reimplements QDialog's \l{QDialog::}{accept()} slot.
|
||||||
This slot is called when the user clicks \gui{Finish}.
|
This slot is called when the user clicks \uicontrol{Finish}.
|
||||||
|
|
||||||
Here's the constructor:
|
Here's the constructor:
|
||||||
|
|
||||||
@ -108,7 +108,7 @@
|
|||||||
\snippet examples/dialogs/classwizard/classwizard.cpp 5
|
\snippet examples/dialogs/classwizard/classwizard.cpp 5
|
||||||
\snippet examples/dialogs/classwizard/classwizard.cpp 6
|
\snippet examples/dialogs/classwizard/classwizard.cpp 6
|
||||||
|
|
||||||
If the user clicks \gui Finish, we extract the information from
|
If the user clicks \uicontrol Finish, we extract the information from
|
||||||
the various pages using QWizard::field() and generate the files.
|
the various pages using QWizard::field() and generate the files.
|
||||||
The code is long and tedious (and has barely anything to do with
|
The code is long and tedious (and has barely anything to do with
|
||||||
noble art of designing wizards), so most of it is skipped here.
|
noble art of designing wizards), so most of it is skipped here.
|
||||||
@ -157,7 +157,7 @@
|
|||||||
layouts. The \c className field is created with an asterisk (\c
|
layouts. The \c className field is created with an asterisk (\c
|
||||||
*) next to its name. This makes it a \l{mandatory field}, that
|
*) next to its name. This makes it a \l{mandatory field}, that
|
||||||
is, a field that must be filled before the user can press the
|
is, a field that must be filled before the user can press the
|
||||||
\gui Next button (\gui Continue on Mac OS X). The fields' values
|
\uicontrol Next button (\uicontrol Continue on Mac OS X). The fields' values
|
||||||
can be accessed from any other page using QWizardPage::field(),
|
can be accessed from any other page using QWizardPage::field(),
|
||||||
or from the wizard code using QWizard::field().
|
or from the wizard code using QWizard::field().
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@
|
|||||||
concerned with the type, we can simplify the signatures of both the
|
concerned with the type, we can simplify the signatures of both the
|
||||||
signal and slot when we make the connection.
|
signal and slot when we make the connection.
|
||||||
|
|
||||||
When the user clicks on the \gui{Send message} button in either window,
|
When the user clicks on the \uicontrol{Send message} button in either window,
|
||||||
the message shown will be emitted in a signal that the other window will
|
the message shown will be emitted in a signal that the other window will
|
||||||
receive and display.
|
receive and display.
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@
|
|||||||
|
|
||||||
\snippet examples/mainwindows/dockwidgets/mainwindow.cpp 5
|
\snippet examples/mainwindows/dockwidgets/mainwindow.cpp 5
|
||||||
|
|
||||||
If the focus is in the QTextEdit, pressing \key Ctrl+Z undoes as
|
If the focus is in the QTextEdit, pressing \uicontrol Ctrl+Z undoes as
|
||||||
expected. But for the user's convenience we provide an
|
expected. But for the user's convenience we provide an
|
||||||
application-wide undo function that simply calls the QTextEdit's
|
application-wide undo function that simply calls the QTextEdit's
|
||||||
undo: this means that the user can undo regardless of where the
|
undo: this means that the user can undo regardless of where the
|
||||||
|
@ -194,7 +194,7 @@
|
|||||||
|
|
||||||
\snippet examples/sql/drilldown/informationwindow.cpp 6
|
\snippet examples/sql/drilldown/informationwindow.cpp 6
|
||||||
|
|
||||||
The \c revert() slot is triggered whenever the user hits the \gui
|
The \c revert() slot is triggered whenever the user hits the \uicontrol
|
||||||
Revert button.
|
Revert button.
|
||||||
|
|
||||||
Since we set the QDataWidgetMapper::ManualSubmit submit policy,
|
Since we set the QDataWidgetMapper::ManualSubmit submit policy,
|
||||||
@ -207,7 +207,7 @@
|
|||||||
\snippet examples/sql/drilldown/informationwindow.cpp 7
|
\snippet examples/sql/drilldown/informationwindow.cpp 7
|
||||||
|
|
||||||
Likewise, the \c submit() slot is triggered whenever the users
|
Likewise, the \c submit() slot is triggered whenever the users
|
||||||
decide to submit their changes by pressing the \gui Submit button.
|
decide to submit their changes by pressing the \uicontrol Submit button.
|
||||||
|
|
||||||
We use QDataWidgetMapper's \l {QDataWidgetMapper::}{submit()} slot
|
We use QDataWidgetMapper's \l {QDataWidgetMapper::}{submit()} slot
|
||||||
to submit all changes from the mapped widgets to the model,
|
to submit all changes from the mapped widgets to the model,
|
||||||
@ -228,12 +228,12 @@
|
|||||||
The \c createButtons() function is provided for convenience, i.e.,
|
The \c createButtons() function is provided for convenience, i.e.,
|
||||||
to simplify the constructor.
|
to simplify the constructor.
|
||||||
|
|
||||||
We make the \gui Close button the default button, i.e., the button
|
We make the \uicontrol Close button the default button, i.e., the button
|
||||||
that is pressed when the user presses \gui Enter, and connect its
|
that is pressed when the user presses \uicontrol Enter, and connect its
|
||||||
\l {QPushButton::}{clicked()} signal to the widget's \l
|
\l {QPushButton::}{clicked()} signal to the widget's \l
|
||||||
{QWidget::}{close()} slot. As mentioned above closing the window
|
{QWidget::}{close()} slot. As mentioned above closing the window
|
||||||
only hides the widget; it is not deleted. We also connect the \gui
|
only hides the widget; it is not deleted. We also connect the \uicontrol
|
||||||
Submit and \gui Revert buttons to the corresponding \c submit()
|
Submit and \uicontrol Revert buttons to the corresponding \c submit()
|
||||||
and \c revert() slots.
|
and \c revert() slots.
|
||||||
|
|
||||||
\snippet examples/sql/drilldown/informationwindow.cpp 9
|
\snippet examples/sql/drilldown/informationwindow.cpp 9
|
||||||
@ -247,8 +247,8 @@
|
|||||||
automatically using the appropriate layout for the user's desktop
|
automatically using the appropriate layout for the user's desktop
|
||||||
environment.
|
environment.
|
||||||
|
|
||||||
Most buttons for a dialog follow certain roles. We give the \gui
|
Most buttons for a dialog follow certain roles. We give the \uicontrol
|
||||||
Submit and \gui Revert buttons the \l
|
Submit and \uicontrol Revert buttons the \l
|
||||||
{QDialogButtonBox::ButtonRole}{reset} role, i.e., indicating that
|
{QDialogButtonBox::ButtonRole}{reset} role, i.e., indicating that
|
||||||
pressing the button resets the fields to the default values (in
|
pressing the button resets the fields to the default values (in
|
||||||
our case the information contained in the database). The \l
|
our case the information contained in the database). The \l
|
||||||
|
@ -38,13 +38,13 @@
|
|||||||
The Extension application is a dialog that allows the user to
|
The Extension application is a dialog that allows the user to
|
||||||
perform a simple search as well as a more advanced search.
|
perform a simple search as well as a more advanced search.
|
||||||
|
|
||||||
The simple search has two options: \gui {Match case} and \gui
|
The simple search has two options: \uicontrol {Match case} and \uicontrol
|
||||||
{Search from start}. The advanced search options include the
|
{Search from start}. The advanced search options include the
|
||||||
possibilities to search for \gui {Whole words}, \gui {Search
|
possibilities to search for \uicontrol {Whole words}, \uicontrol {Search
|
||||||
backward} and \gui {Search selection}. Only the simple search is
|
backward} and \uicontrol {Search selection}. Only the simple search is
|
||||||
visible when the application starts. The advanced search options
|
visible when the application starts. The advanced search options
|
||||||
are located in the application's extension part, and can be made
|
are located in the application's extension part, and can be made
|
||||||
visible by pressing the \gui More button:
|
visible by pressing the \uicontrol More button:
|
||||||
|
|
||||||
\image extension_more.png Screenshot of the Extension example
|
\image extension_more.png Screenshot of the Extension example
|
||||||
|
|
||||||
@ -65,8 +65,8 @@
|
|||||||
widgets: We need a QLineEdit with an associated QLabel to let the
|
widgets: We need a QLineEdit with an associated QLabel to let the
|
||||||
user type a word to search for, we need several \l
|
user type a word to search for, we need several \l
|
||||||
{QCheckBox}{QCheckBox}es to facilitate the search options, and we
|
{QCheckBox}{QCheckBox}es to facilitate the search options, and we
|
||||||
need three \l {QPushButton}{QPushButton}s: the \gui Find button to
|
need three \l {QPushButton}{QPushButton}s: the \uicontrol Find button to
|
||||||
start a search and the \gui More button to enable an advanced search.
|
start a search and the \uicontrol More button to enable an advanced search.
|
||||||
Finally, we need a QWidget representing the application's extension
|
Finally, we need a QWidget representing the application's extension
|
||||||
part.
|
part.
|
||||||
|
|
||||||
@ -80,13 +80,13 @@
|
|||||||
\snippet examples/dialogs/extension/finddialog.cpp 0
|
\snippet examples/dialogs/extension/finddialog.cpp 0
|
||||||
|
|
||||||
We give the options and buttons a shortcut key using the &
|
We give the options and buttons a shortcut key using the &
|
||||||
character. In the \gui {Find what} option's case, we also need to
|
character. In the \uicontrol {Find what} option's case, we also need to
|
||||||
use the QLabel::setBuddy() function to make the shortcut key work
|
use the QLabel::setBuddy() function to make the shortcut key work
|
||||||
as expected; then, when the user presses the shortcut key
|
as expected; then, when the user presses the shortcut key
|
||||||
indicated by the label, the keyboard focus is transferred to the
|
indicated by the label, the keyboard focus is transferred to the
|
||||||
label's buddy widget, the QLineEdit.
|
label's buddy widget, the QLineEdit.
|
||||||
|
|
||||||
We set the \gui Find button's default property to true, using the
|
We set the \uicontrol Find button's default property to true, using the
|
||||||
QPushButton::setDefault() function. Then the push button will be
|
QPushButton::setDefault() function. Then the push button will be
|
||||||
pressed if the user presses the Enter (or Return) key. Note that a
|
pressed if the user presses the Enter (or Return) key. Note that a
|
||||||
QDialog can only have one default button.
|
QDialog can only have one default button.
|
||||||
@ -99,7 +99,7 @@
|
|||||||
|
|
||||||
\snippet examples/dialogs/extension/finddialog.cpp 3
|
\snippet examples/dialogs/extension/finddialog.cpp 3
|
||||||
|
|
||||||
Now that the extension widget is created, we can connect the \gui
|
Now that the extension widget is created, we can connect the \uicontrol
|
||||||
More button's \l{QAbstractButton::toggled()}{toggled()} signal to
|
More button's \l{QAbstractButton::toggled()}{toggled()} signal to
|
||||||
the extension widget's \l{QWidget::setVisible()}{setVisible()} slot.
|
the extension widget's \l{QWidget::setVisible()}{setVisible()} slot.
|
||||||
|
|
||||||
@ -110,9 +110,9 @@
|
|||||||
the status is true the widget is shown, otherwise the widget is
|
the status is true the widget is shown, otherwise the widget is
|
||||||
hidden.
|
hidden.
|
||||||
|
|
||||||
Since we made the \gui More button checkable when we created it,
|
Since we made the \uicontrol More button checkable when we created it,
|
||||||
the connection makes sure that the extension widget is shown
|
the connection makes sure that the extension widget is shown
|
||||||
depending on the state of \gui More button.
|
depending on the state of \uicontrol More button.
|
||||||
|
|
||||||
We also put the check boxes associated with the advanced
|
We also put the check boxes associated with the advanced
|
||||||
search options into a layout we install on the extension widget.
|
search options into a layout we install on the extension widget.
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
\image fetchmore-example.png
|
\image fetchmore-example.png
|
||||||
|
|
||||||
The user of the example can enter a directory in the \gui
|
The user of the example can enter a directory in the \uicontrol
|
||||||
Directory line edit. The contents of the directory will
|
Directory line edit. The contents of the directory will
|
||||||
be listed in the list view below.
|
be listed in the list view below.
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
specified directory, matching a specified file name (using wild
|
specified directory, matching a specified file name (using wild
|
||||||
cards if appropriate) and containing a specified text.
|
cards if appropriate) and containing a specified text.
|
||||||
|
|
||||||
The user is provided with a \gui Browse option, and the result of
|
The user is provided with a \uicontrol Browse option, and the result of
|
||||||
the search is displayed in a table with the names of the files
|
the search is displayed in a table with the names of the files
|
||||||
found and their sizes. In addition the application provides a
|
found and their sizes. In addition the application provides a
|
||||||
total count of the files found.
|
total count of the files found.
|
||||||
@ -59,7 +59,7 @@
|
|||||||
We need two private slots: The \c browse() slot is called whenever
|
We need two private slots: The \c browse() slot is called whenever
|
||||||
the user wants to browse for a directory to search in, and the \c
|
the user wants to browse for a directory to search in, and the \c
|
||||||
find() slot is called whenever the user requests a search to be
|
find() slot is called whenever the user requests a search to be
|
||||||
performed by pressing the \gui Find button.
|
performed by pressing the \uicontrol Find button.
|
||||||
|
|
||||||
In addition we declare several private functions: We use the \c
|
In addition we declare several private functions: We use the \c
|
||||||
findFiles() function to search for files matching the user's
|
findFiles() function to search for files matching the user's
|
||||||
@ -109,7 +109,7 @@
|
|||||||
\snippet examples/dialogs/findfiles/window.cpp 3
|
\snippet examples/dialogs/findfiles/window.cpp 3
|
||||||
|
|
||||||
The \c find() slot is called whenever the user requests a new
|
The \c find() slot is called whenever the user requests a new
|
||||||
search by pressing the \gui Find button.
|
search by pressing the \uicontrol Find button.
|
||||||
|
|
||||||
First we eliminate any previous search results by setting the
|
First we eliminate any previous search results by setting the
|
||||||
table widgets row count to zero. Then we retrieve the
|
table widgets row count to zero. Then we retrieve the
|
||||||
|
@ -90,13 +90,13 @@
|
|||||||
\dots
|
\dots
|
||||||
\snippet examples/network/fortuneclient/client.cpp 5
|
\snippet examples/network/fortuneclient/client.cpp 5
|
||||||
|
|
||||||
Clicking the \gui{Get Fortune} button will invoke the \c
|
Clicking the \uicontrol{Get Fortune} button will invoke the \c
|
||||||
requestNewFortune() slot:
|
requestNewFortune() slot:
|
||||||
|
|
||||||
\snippet examples/network/fortuneclient/client.cpp 6
|
\snippet examples/network/fortuneclient/client.cpp 6
|
||||||
|
|
||||||
In this slot, we initialize \c blockSize to 0, preparing to read a new block
|
In this slot, we initialize \c blockSize to 0, preparing to read a new block
|
||||||
of data. Because we allow the user to click \gui{Get Fortune} before the
|
of data. Because we allow the user to click \uicontrol{Get Fortune} before the
|
||||||
previous connection finished closing, we start off by aborting the
|
previous connection finished closing, we start off by aborting the
|
||||||
previous connection by calling QTcpSocket::abort(). (On an unconnected
|
previous connection by calling QTcpSocket::abort(). (On an unconnected
|
||||||
socket, this function does nothing.) We then proceed to connecting to the
|
socket, this function does nothing.) We then proceed to connecting to the
|
||||||
|
@ -145,10 +145,10 @@
|
|||||||
|
|
||||||
You should now see the text "QPushButton" in the top left pane.
|
You should now see the text "QPushButton" in the top left pane.
|
||||||
Double-click it, then click on "Hello world!" and enter "Orbis, te
|
Double-click it, then click on "Hello world!" and enter "Orbis, te
|
||||||
saluto!" in the \gui Translation pane (the middle right of the
|
saluto!" in the \uicontrol Translation pane (the middle right of the
|
||||||
window). Don't forget the exclamation mark!
|
window). Don't forget the exclamation mark!
|
||||||
|
|
||||||
Click the \gui Done checkbox and choose \gui File|Save from the
|
Click the \uicontrol Done checkbox and choose \uicontrol File|Save from the
|
||||||
menu bar. The TS file will no longer contain
|
menu bar. The TS file will no longer contain
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/doc_src_examples_hellotr.qdoc 3
|
\snippet doc/src/snippets/code/doc_src_examples_hellotr.qdoc 3
|
||||||
@ -165,8 +165,8 @@
|
|||||||
by using the command line program \c lrelease which will produce one
|
by using the command line program \c lrelease which will produce one
|
||||||
QM file for each of the TS files listed in the project file.
|
QM file for each of the TS files listed in the project file.
|
||||||
Generate \c hellotr_la.qm from \c hellotr_la.ts by choosing
|
Generate \c hellotr_la.qm from \c hellotr_la.ts by choosing
|
||||||
\gui File|Release from \e {Qt Linguist}'s menu bar and pressing
|
\uicontrol File|Release from \e {Qt Linguist}'s menu bar and pressing
|
||||||
\gui Save in the file save dialog that pops up. Now run the \c hellotr
|
\uicontrol Save in the file save dialog that pops up. Now run the \c hellotr
|
||||||
program again. This time the button will be labelled "Orbis, te
|
program again. This time the button will be labelled "Orbis, te
|
||||||
saluto!".
|
saluto!".
|
||||||
|
|
||||||
|
@ -99,23 +99,23 @@
|
|||||||
dependent, but most of the styles have the same values: Only the
|
dependent, but most of the styles have the same values: Only the
|
||||||
Macintosh style differ by using 32 pixels, instead of 16 pixels,
|
Macintosh style differ by using 32 pixels, instead of 16 pixels,
|
||||||
for toolbar buttons. You can navigate between the available styles
|
for toolbar buttons. You can navigate between the available styles
|
||||||
using the \gui View menu.
|
using the \uicontrol View menu.
|
||||||
|
|
||||||
\image icons-view-menu.png Screenshot of the View menu
|
\image icons-view-menu.png Screenshot of the View menu
|
||||||
|
|
||||||
The \gui View menu also provide the option to make the application
|
The \uicontrol View menu also provide the option to make the application
|
||||||
guess the icon state and mode from an image's file name. The \gui
|
guess the icon state and mode from an image's file name. The \uicontrol
|
||||||
File menu provide the options of adding an image and removing all
|
File menu provide the options of adding an image and removing all
|
||||||
images. These last options are also available through a context
|
images. These last options are also available through a context
|
||||||
menu that appears if you press the right mouse button within the
|
menu that appears if you press the right mouse button within the
|
||||||
table of image files. In addition, the \gui File menu provide an
|
table of image files. In addition, the \uicontrol File menu provide an
|
||||||
\gui Exit option, and the \gui Help menu provide information about
|
\uicontrol Exit option, and the \uicontrol Help menu provide information about
|
||||||
the example and about Qt.
|
the example and about Qt.
|
||||||
|
|
||||||
\image icons_find_normal.png Screenshot of the Find Files
|
\image icons_find_normal.png Screenshot of the Find Files
|
||||||
|
|
||||||
The screenshot above shows the application with one image file
|
The screenshot above shows the application with one image file
|
||||||
loaded. The \gui {Guess Image Mode/State} is enabled and the
|
loaded. The \uicontrol {Guess Image Mode/State} is enabled and the
|
||||||
style is Plastique.
|
style is Plastique.
|
||||||
|
|
||||||
When QIcon is provided with only one available pixmap, that
|
When QIcon is provided with only one available pixmap, that
|
||||||
@ -127,7 +127,7 @@
|
|||||||
|
|
||||||
The next screenshot shows the application with an additional file
|
The next screenshot shows the application with an additional file
|
||||||
loaded, providing QIcon with two available pixmaps. Note that the
|
loaded, providing QIcon with two available pixmaps. Note that the
|
||||||
new image file's mode is set to disabled. When rendering the \gui
|
new image file's mode is set to disabled. When rendering the \uicontrol
|
||||||
Disabled mode pixmaps, Qt will now use the new image. We can see
|
Disabled mode pixmaps, Qt will now use the new image. We can see
|
||||||
the difference: The generated disabled pixmap in the first
|
the difference: The generated disabled pixmap in the first
|
||||||
screenshot is slightly darker than the pixmap with the originally
|
screenshot is slightly darker than the pixmap with the originally
|
||||||
@ -451,7 +451,7 @@
|
|||||||
\snippet examples/widgets/icons/mainwindow.cpp 17
|
\snippet examples/widgets/icons/mainwindow.cpp 17
|
||||||
|
|
||||||
Then we create the second and third items in the row making the
|
Then we create the second and third items in the row making the
|
||||||
default mode Normal and the default state Off. But if the \gui
|
default mode Normal and the default state Off. But if the \uicontrol
|
||||||
{Guess Image Mode/State} option is checked, and the file name
|
{Guess Image Mode/State} option is checked, and the file name
|
||||||
contains "_act", "_dis", or "_sel", the modes are changed to
|
contains "_act", "_dis", or "_sel", the modes are changed to
|
||||||
Active, Disabled, or Selected. And if the file name contains
|
Active, Disabled, or Selected. And if the file name contains
|
||||||
@ -605,7 +605,7 @@
|
|||||||
\snippet examples/widgets/icons/mainwindow.cpp 29
|
\snippet examples/widgets/icons/mainwindow.cpp 29
|
||||||
|
|
||||||
In the \c createMenu() function, we add the previously created
|
In the \c createMenu() function, we add the previously created
|
||||||
actions to the \gui File, \gui View and \gui Help menus.
|
actions to the \uicontrol File, \uicontrol View and \uicontrol Help menus.
|
||||||
|
|
||||||
The QMenu class provides a menu widget for use in menu bars,
|
The QMenu class provides a menu widget for use in menu bars,
|
||||||
context menus, and other popup menus. We put each menu in the
|
context menus, and other popup menus. We put each menu in the
|
||||||
@ -621,7 +621,7 @@
|
|||||||
meaning that the \l{QAction}s associated with the widget should
|
meaning that the \l{QAction}s associated with the widget should
|
||||||
appear in its context menu.
|
appear in its context menu.
|
||||||
|
|
||||||
Then we add the \gui{Add Image} and \gui{Remove All Images}
|
Then we add the \uicontrol{Add Image} and \uicontrol{Remove All Images}
|
||||||
actions to the table widget. They will then appear in the table
|
actions to the table widget. They will then appear in the table
|
||||||
widget's context menu.
|
widget's context menu.
|
||||||
|
|
||||||
@ -692,7 +692,7 @@
|
|||||||
characters. If the first and second numbers of the spin box value
|
characters. If the first and second numbers of the spin box value
|
||||||
differ (e.g., "16 x 24"), we use the first number.
|
differ (e.g., "16 x 24"), we use the first number.
|
||||||
|
|
||||||
When the user presses \key Enter, QSpinBox first calls
|
When the user presses \uicontrol Enter, QSpinBox first calls
|
||||||
QSpinBox::valueFromText() to interpret the text typed by the
|
QSpinBox::valueFromText() to interpret the text typed by the
|
||||||
user, then QSpinBox::textFromValue() to present it in a canonical
|
user, then QSpinBox::textFromValue() to present it in a canonical
|
||||||
format (e.g., "16 x 16").
|
format (e.g., "16 x 16").
|
||||||
|
@ -45,25 +45,25 @@
|
|||||||
\image imageviewer-example.png Screenshot of the Image Viewer example
|
\image imageviewer-example.png Screenshot of the Image Viewer example
|
||||||
|
|
||||||
With the Image Viewer application, the users can view an image of
|
With the Image Viewer application, the users can view an image of
|
||||||
their choice. The \gui File menu gives the user the possibility
|
their choice. The \uicontrol File menu gives the user the possibility
|
||||||
to:
|
to:
|
||||||
|
|
||||||
\list
|
\list
|
||||||
\li \gui{Open...} - Open an image file
|
\li \uicontrol{Open...} - Open an image file
|
||||||
\li \gui{Print...} - Print an image
|
\li \uicontrol{Print...} - Print an image
|
||||||
\li \gui{Exit} - Exit the application
|
\li \uicontrol{Exit} - Exit the application
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
Once an image is loaded, the \gui View menu allows the users to:
|
Once an image is loaded, the \uicontrol View menu allows the users to:
|
||||||
|
|
||||||
\list
|
\list
|
||||||
\li \gui{Zoom In} - Scale the image up by 25%
|
\li \uicontrol{Zoom In} - Scale the image up by 25%
|
||||||
\li \gui{Zoom Out} - Scale the image down by 25%
|
\li \uicontrol{Zoom Out} - Scale the image down by 25%
|
||||||
\li \gui{Normal Size} - Show the image at its original size
|
\li \uicontrol{Normal Size} - Show the image at its original size
|
||||||
\li \gui{Fit to Window} - Stretch the image to occupy the entire window
|
\li \uicontrol{Fit to Window} - Stretch the image to occupy the entire window
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
In addition the \gui Help menu provides the users with information
|
In addition the \uicontrol Help menu provides the users with information
|
||||||
about the Image Viewer example in particular, and about Qt in
|
about the Image Viewer example in particular, and about Qt in
|
||||||
general.
|
general.
|
||||||
|
|
||||||
@ -78,7 +78,7 @@
|
|||||||
We use \c createActions() and \c createMenus() when constructing
|
We use \c createActions() and \c createMenus() when constructing
|
||||||
the \c ImageViewer widget. We use the \c updateActions() function
|
the \c ImageViewer widget. We use the \c updateActions() function
|
||||||
to update the menu entries when a new image is loaded, or when
|
to update the menu entries when a new image is loaded, or when
|
||||||
the \gui {Fit to Window} option is toggled. The zoom slots use \c
|
the \uicontrol {Fit to Window} option is toggled. The zoom slots use \c
|
||||||
scaleImage() to perform the zooming. In turn, \c
|
scaleImage() to perform the zooming. In turn, \c
|
||||||
scaleImage() uses \c adjustScrollBar() to preserve the focal point after
|
scaleImage() uses \c adjustScrollBar() to preserve the focal point after
|
||||||
scaling an image.
|
scaling an image.
|
||||||
@ -91,7 +91,7 @@
|
|||||||
|
|
||||||
We set \c {imageLabel}'s size policy to \l
|
We set \c {imageLabel}'s size policy to \l
|
||||||
{QSizePolicy::Ignored}{ignored}, making the users able to scale
|
{QSizePolicy::Ignored}{ignored}, making the users able to scale
|
||||||
the image to whatever size they want when the \gui {Fit to Window}
|
the image to whatever size they want when the \uicontrol {Fit to Window}
|
||||||
option is turned on. Otherwise, the default size polizy (\l
|
option is turned on. Otherwise, the default size polizy (\l
|
||||||
{QSizePolicy::Preferred}{preferred}) will make scroll bars appear
|
{QSizePolicy::Preferred}{preferred}) will make scroll bars appear
|
||||||
when the scroll area becomes smaller than the label's minimum size
|
when the scroll area becomes smaller than the label's minimum size
|
||||||
@ -115,7 +115,7 @@
|
|||||||
In the \c open() slot, we show a file dialog to the user. The
|
In the \c open() slot, we show a file dialog to the user. The
|
||||||
easiest way to create a QFileDialog is to use the static
|
easiest way to create a QFileDialog is to use the static
|
||||||
convenience functions. QFileDialog::getOpenFileName() returns an
|
convenience functions. QFileDialog::getOpenFileName() returns an
|
||||||
existing file selected by the user. If the user presses \gui
|
existing file selected by the user. If the user presses \uicontrol
|
||||||
Cancel, QFileDialog returns an empty string.
|
Cancel, QFileDialog returns an empty string.
|
||||||
|
|
||||||
Unless the file name is a empty string, we check if the file's
|
Unless the file name is a empty string, we check if the file's
|
||||||
@ -130,7 +130,7 @@
|
|||||||
messages arranged along two axes: severity (question,
|
messages arranged along two axes: severity (question,
|
||||||
information, warning and critical) and complexity (the number of
|
information, warning and critical) and complexity (the number of
|
||||||
necessary response buttons). In this particular example an
|
necessary response buttons). In this particular example an
|
||||||
information message with an \gui OK button (the default) is
|
information message with an \uicontrol OK button (the default) is
|
||||||
sufficient, since the message is part of a normal operation.
|
sufficient, since the message is part of a normal operation.
|
||||||
|
|
||||||
\snippet examples/widgets/imageviewer/imageviewer.cpp 3
|
\snippet examples/widgets/imageviewer/imageviewer.cpp 3
|
||||||
@ -138,11 +138,11 @@
|
|||||||
|
|
||||||
If the format is supported, we display the image in \c imageLabel
|
If the format is supported, we display the image in \c imageLabel
|
||||||
by setting the label's \l {QLabel::pixmap}{pixmap}. Then we enable
|
by setting the label's \l {QLabel::pixmap}{pixmap}. Then we enable
|
||||||
the \gui Print and \gui {Fit to Window} menu entries and update
|
the \uicontrol Print and \uicontrol {Fit to Window} menu entries and update
|
||||||
the rest of the view menu entries. The \gui Open and \gui Exit
|
the rest of the view menu entries. The \uicontrol Open and \uicontrol Exit
|
||||||
entries are enabled by default.
|
entries are enabled by default.
|
||||||
|
|
||||||
If the \gui {Fit to Window} option is turned off, the
|
If the \uicontrol {Fit to Window} option is turned off, the
|
||||||
QScrollArea::widgetResizable property is \c false and it is
|
QScrollArea::widgetResizable property is \c false and it is
|
||||||
our responsibility (not QScrollArea's) to give the QLabel a
|
our responsibility (not QScrollArea's) to give the QLabel a
|
||||||
reasonable size based on its contents. We call
|
reasonable size based on its contents. We call
|
||||||
@ -164,7 +164,7 @@
|
|||||||
|
|
||||||
In release mode, the macro simply disappear. The mode can be set
|
In release mode, the macro simply disappear. The mode can be set
|
||||||
in the application's \c .pro file. One way to do so is to add an
|
in the application's \c .pro file. One way to do so is to add an
|
||||||
option to \gui qmake when building the application:
|
option to \uicontrol qmake when building the application:
|
||||||
|
|
||||||
\snippet doc/src/snippets/code/doc_src_examples_imageviewer.qdoc 2
|
\snippet doc/src/snippets/code/doc_src_examples_imageviewer.qdoc 2
|
||||||
|
|
||||||
@ -192,8 +192,8 @@
|
|||||||
|
|
||||||
We implement the zooming slots using the private \c scaleImage()
|
We implement the zooming slots using the private \c scaleImage()
|
||||||
function. We set the scaling factors to 1.25 and 0.8,
|
function. We set the scaling factors to 1.25 and 0.8,
|
||||||
respectively. These factor values ensure that a \gui {Zoom In}
|
respectively. These factor values ensure that a \uicontrol {Zoom In}
|
||||||
action and a \gui {Zoom Out} action will cancel each other (since
|
action and a \uicontrol {Zoom Out} action will cancel each other (since
|
||||||
1.25 * 0.8 == 1), and in that way the normal image size can be
|
1.25 * 0.8 == 1), and in that way the normal image size can be
|
||||||
restored using the zooming features.
|
restored using the zooming features.
|
||||||
|
|
||||||
@ -221,10 +221,10 @@
|
|||||||
\snippet examples/widgets/imageviewer/imageviewer.cpp 14
|
\snippet examples/widgets/imageviewer/imageviewer.cpp 14
|
||||||
|
|
||||||
The \c fitToWindow() slot is called each time the user toggled
|
The \c fitToWindow() slot is called each time the user toggled
|
||||||
the \gui {Fit to Window} option. If the slot is called to turn on
|
the \uicontrol {Fit to Window} option. If the slot is called to turn on
|
||||||
the option, we tell the scroll area to resize its child widget
|
the option, we tell the scroll area to resize its child widget
|
||||||
with the QScrollArea::setWidgetResizable() function. Then we
|
with the QScrollArea::setWidgetResizable() function. Then we
|
||||||
disable the \gui {Zoom In}, \gui {Zoom Out} and \gui {Normal
|
disable the \uicontrol {Zoom In}, \uicontrol {Zoom Out} and \uicontrol {Normal
|
||||||
Size} menu entries using the private \c updateActions() function.
|
Size} menu entries using the private \c updateActions() function.
|
||||||
|
|
||||||
If the \l {QScrollArea::widgetResizable} property is set to \c
|
If the \l {QScrollArea::widgetResizable} property is set to \c
|
||||||
@ -240,7 +240,7 @@
|
|||||||
label's minimum size hint.
|
label's minimum size hint.
|
||||||
|
|
||||||
The screenshots below shows an image in its normal size, and the
|
The screenshots below shows an image in its normal size, and the
|
||||||
same image with the \gui {Fit to window} option turned on.
|
same image with the \uicontrol {Fit to window} option turned on.
|
||||||
Enlarging the window will stretch the image further, as shown in
|
Enlarging the window will stretch the image further, as shown in
|
||||||
the third screenshot.
|
the third screenshot.
|
||||||
|
|
||||||
@ -279,7 +279,7 @@
|
|||||||
\snippet examples/widgets/imageviewer/imageviewer.cpp 20
|
\snippet examples/widgets/imageviewer/imageviewer.cpp 20
|
||||||
|
|
||||||
In the private \c createMenu() function, we add the previously
|
In the private \c createMenu() function, we add the previously
|
||||||
created actions to the \gui File, \gui View and \gui Help menus.
|
created actions to the \uicontrol File, \uicontrol View and \uicontrol Help menus.
|
||||||
|
|
||||||
The QMenu class provides a menu widget for use in menu bars,
|
The QMenu class provides a menu widget for use in menu bars,
|
||||||
context menus, and other popup menus. The QMenuBar class provides
|
context menus, and other popup menus. The QMenuBar class provides
|
||||||
@ -292,8 +292,8 @@
|
|||||||
\snippet examples/widgets/imageviewer/imageviewer.cpp 22
|
\snippet examples/widgets/imageviewer/imageviewer.cpp 22
|
||||||
|
|
||||||
The private \c updateActions() function enables or disables the
|
The private \c updateActions() function enables or disables the
|
||||||
\gui {Zoom In}, \gui {Zoom Out} and \gui {Normal Size} menu
|
\uicontrol {Zoom In}, \uicontrol {Zoom Out} and \uicontrol {Normal Size} menu
|
||||||
entries depending on whether the \gui {Fit to Window} option is
|
entries depending on whether the \uicontrol {Fit to Window} option is
|
||||||
turned on or off.
|
turned on or off.
|
||||||
|
|
||||||
\snippet examples/widgets/imageviewer/imageviewer.cpp 23
|
\snippet examples/widgets/imageviewer/imageviewer.cpp 23
|
||||||
|
@ -98,7 +98,7 @@
|
|||||||
\snippet examples/dialogs/licensewizard/licensewizard.cpp 5
|
\snippet examples/dialogs/licensewizard/licensewizard.cpp 5
|
||||||
\snippet examples/dialogs/licensewizard/licensewizard.cpp 6
|
\snippet examples/dialogs/licensewizard/licensewizard.cpp 6
|
||||||
|
|
||||||
We configure the QWizard to show a \gui Help button, which is
|
We configure the QWizard to show a \uicontrol Help button, which is
|
||||||
connected to our \c showHelp() slot. We also set the
|
connected to our \c showHelp() slot. We also set the
|
||||||
\l{QWizard::}{LogoPixmap} for all pages that have a header (i.e.,
|
\l{QWizard::}{LogoPixmap} for all pages that have a header (i.e.,
|
||||||
\c EvaluatePage, \c RegisterPage, and \c DetailsPage).
|
\c EvaluatePage, \c RegisterPage, and \c DetailsPage).
|
||||||
@ -109,7 +109,7 @@
|
|||||||
\snippet examples/dialogs/licensewizard/licensewizard.cpp 13
|
\snippet examples/dialogs/licensewizard/licensewizard.cpp 13
|
||||||
|
|
||||||
In \c showHelp(), we display help texts that are appropriate for
|
In \c showHelp(), we display help texts that are appropriate for
|
||||||
the current page. If the user clicks \gui Help twice for the same
|
the current page. If the user clicks \uicontrol Help twice for the same
|
||||||
page, we say, "Sorry, I already gave what help I could. Maybe you
|
page, we say, "Sorry, I already gave what help I could. Maybe you
|
||||||
should try asking a human?"
|
should try asking a human?"
|
||||||
|
|
||||||
@ -136,7 +136,7 @@
|
|||||||
\snippet examples/dialogs/licensewizard/licensewizard.cpp 19
|
\snippet examples/dialogs/licensewizard/licensewizard.cpp 19
|
||||||
|
|
||||||
The \c nextId() function returns the ID for \c EvaluatePage if
|
The \c nextId() function returns the ID for \c EvaluatePage if
|
||||||
the \gui{Evaluate the product for 30 days} option is checked;
|
the \uicontrol{Evaluate the product for 30 days} option is checked;
|
||||||
otherwise it returns the ID for \c RegisterPage.
|
otherwise it returns the ID for \c RegisterPage.
|
||||||
|
|
||||||
\section1 The EvaluatePage Class
|
\section1 The EvaluatePage Class
|
||||||
@ -159,7 +159,7 @@
|
|||||||
layouts. The fields are created with an asterisk (\c
|
layouts. The fields are created with an asterisk (\c
|
||||||
*) next to their name. This makes them \l{mandatory fields}, that
|
*) next to their name. This makes them \l{mandatory fields}, that
|
||||||
is, fields that must be filled before the user can press the
|
is, fields that must be filled before the user can press the
|
||||||
\gui Next button (\gui Continue on Mac OS X). The fields' values
|
\uicontrol Next button (\uicontrol Continue on Mac OS X). The fields' values
|
||||||
can be accessed from any other page using QWizardPage::field().
|
can be accessed from any other page using QWizardPage::field().
|
||||||
|
|
||||||
Resetting the page amounts to clearing the two text fields.
|
Resetting the page amounts to clearing the two text fields.
|
||||||
@ -201,13 +201,13 @@
|
|||||||
|
|
||||||
\snippet examples/dialogs/licensewizard/licensewizard.cpp 28
|
\snippet examples/dialogs/licensewizard/licensewizard.cpp 28
|
||||||
|
|
||||||
We want to display a \gui Print button in the wizard when the \c
|
We want to display a \uicontrol Print button in the wizard when the \c
|
||||||
ConclusionPage is up. One way to accomplish this is to reimplement
|
ConclusionPage is up. One way to accomplish this is to reimplement
|
||||||
QWidget::setVisible():
|
QWidget::setVisible():
|
||||||
|
|
||||||
\list
|
\list
|
||||||
\li If the page is shown, we set the \l{QWizard::}{CustomButton1} button's
|
\li If the page is shown, we set the \l{QWizard::}{CustomButton1} button's
|
||||||
text to \gui{\underline{P}rint}, we enable the \l{QWizard::}{HaveCustomButton1}
|
text to \uicontrol{\underline{P}rint}, we enable the \l{QWizard::}{HaveCustomButton1}
|
||||||
option, and we connect the QWizard's \l{QWizard::}{customButtonClicked()}
|
option, and we connect the QWizard's \l{QWizard::}{customButtonClicked()}
|
||||||
signal to our \c printButtonClicked() slot.
|
signal to our \c printButtonClicked() slot.
|
||||||
\li If the page is hidden, we disable the \l{QWizard::}{HaveCustomButton1}
|
\li If the page is hidden, we disable the \l{QWizard::}{HaveCustomButton1}
|
||||||
|
@ -115,7 +115,7 @@
|
|||||||
The slots respond to signals emitted when the comboboxes are changed by the
|
The slots respond to signals emitted when the comboboxes are changed by the
|
||||||
user.
|
user.
|
||||||
|
|
||||||
When the combobox for the \gui{Echo} group box is changed, the \c echoChanged()
|
When the combobox for the \uicontrol{Echo} group box is changed, the \c echoChanged()
|
||||||
slot is called:
|
slot is called:
|
||||||
|
|
||||||
\snippet examples/widgets/lineedits/window.cpp 9
|
\snippet examples/widgets/lineedits/window.cpp 9
|
||||||
@ -123,7 +123,7 @@
|
|||||||
The slot updates the line edit in the same group box to use an echo mode that
|
The slot updates the line edit in the same group box to use an echo mode that
|
||||||
corresponds to the entry described in the combobox.
|
corresponds to the entry described in the combobox.
|
||||||
|
|
||||||
When the combobox for the \gui{Validator} group box is changed, the
|
When the combobox for the \uicontrol{Validator} group box is changed, the
|
||||||
\c validatorChanged() slot is called:
|
\c validatorChanged() slot is called:
|
||||||
|
|
||||||
\snippet examples/widgets/lineedits/window.cpp 10
|
\snippet examples/widgets/lineedits/window.cpp 10
|
||||||
@ -133,7 +133,7 @@
|
|||||||
We clear the line edit in this case to ensure that the new validator is
|
We clear the line edit in this case to ensure that the new validator is
|
||||||
initially given valid input to work with.
|
initially given valid input to work with.
|
||||||
|
|
||||||
When the combobox for the \gui{Alignment} group box is changed, the
|
When the combobox for the \uicontrol{Alignment} group box is changed, the
|
||||||
\c alignmentChanged() slot is called:
|
\c alignmentChanged() slot is called:
|
||||||
|
|
||||||
\snippet examples/widgets/lineedits/window.cpp 11
|
\snippet examples/widgets/lineedits/window.cpp 11
|
||||||
@ -142,7 +142,7 @@
|
|||||||
the description selected in the combobox.
|
the description selected in the combobox.
|
||||||
|
|
||||||
The \c inputMaskChanged() slot handles changes to the combobox in the
|
The \c inputMaskChanged() slot handles changes to the combobox in the
|
||||||
\gui{Input Mask} group box:
|
\uicontrol{Input Mask} group box:
|
||||||
|
|
||||||
\snippet examples/widgets/lineedits/window.cpp 12
|
\snippet examples/widgets/lineedits/window.cpp 12
|
||||||
|
|
||||||
@ -151,11 +151,11 @@
|
|||||||
the mask is disabled if an empty string is used.
|
the mask is disabled if an empty string is used.
|
||||||
|
|
||||||
The \c accessChanged() slot handles changes to the combobox in the
|
The \c accessChanged() slot handles changes to the combobox in the
|
||||||
\gui{Access} group box:
|
\uicontrol{Access} group box:
|
||||||
|
|
||||||
\snippet examples/widgets/lineedits/window.cpp 13
|
\snippet examples/widgets/lineedits/window.cpp 13
|
||||||
|
|
||||||
Here, we simply associate the \gui{False} and \gui{True} entries in the combobox
|
Here, we simply associate the \uicontrol{False} and \uicontrol{True} entries in the combobox
|
||||||
with \c false and \c true values to be passed to QLineEdit::setReadOnly(). This
|
with \c false and \c true values to be passed to QLineEdit::setReadOnly(). This
|
||||||
allows the user to enable and disable input to the line edit.
|
allows the user to enable and disable input to the line edit.
|
||||||
*/
|
*/
|
||||||
|
@ -91,8 +91,8 @@
|
|||||||
into widgets.
|
into widgets.
|
||||||
|
|
||||||
In some situations it is useful to group actions together, e.g.,
|
In some situations it is useful to group actions together, e.g.,
|
||||||
we have a \gui {Left Align} action, a \gui {Right Align} action, a
|
we have a \uicontrol {Left Align} action, a \uicontrol {Right Align} action, a
|
||||||
\gui {Justify} action, and a \gui {Center} action, and we want
|
\uicontrol {Justify} action, and a \uicontrol {Center} action, and we want
|
||||||
only one of these actions to be active at any one time. One simple
|
only one of these actions to be active at any one time. One simple
|
||||||
way of achieving this is to group the actions together in an
|
way of achieving this is to group the actions together in an
|
||||||
action group using the QActionGroup class.
|
action group using the QActionGroup class.
|
||||||
@ -141,7 +141,7 @@
|
|||||||
using the provided convenience functions.
|
using the provided convenience functions.
|
||||||
|
|
||||||
In the \c createActions() function, we first create a \c newAct
|
In the \c createActions() function, we first create a \c newAct
|
||||||
action. We make \gui Ctrl+N its shortcut using the
|
action. We make \uicontrol Ctrl+N its shortcut using the
|
||||||
QAction::setShortcut() function, and we set its status tip using the
|
QAction::setShortcut() function, and we set its status tip using the
|
||||||
QAction::setStatusTip() function (the status tip is displayed on all
|
QAction::setStatusTip() function (the status tip is displayed on all
|
||||||
status bars provided by the action's top-level parent widget). We
|
status bars provided by the action's top-level parent widget). We
|
||||||
@ -154,8 +154,8 @@
|
|||||||
\snippet examples/mainwindows/menus/mainwindow.cpp 7
|
\snippet examples/mainwindows/menus/mainwindow.cpp 7
|
||||||
|
|
||||||
|
|
||||||
Once we have created the \gui {Left Align}, \gui {Right Align},
|
Once we have created the \uicontrol {Left Align}, \uicontrol {Right Align},
|
||||||
\gui {Justify}, and a \gui {Center} actions, we can also create
|
\uicontrol {Justify}, and a \uicontrol {Center} actions, we can also create
|
||||||
the previously mentioned action group.
|
the previously mentioned action group.
|
||||||
|
|
||||||
Each action is added to the group using QActionGroup's \l
|
Each action is added to the group using QActionGroup's \l
|
||||||
@ -191,8 +191,8 @@
|
|||||||
|
|
||||||
\snippet examples/mainwindows/menus/mainwindow.cpp 12
|
\snippet examples/mainwindows/menus/mainwindow.cpp 12
|
||||||
|
|
||||||
Note the \gui Format menu. First of all, it is added as a submenu
|
Note the \uicontrol Format menu. First of all, it is added as a submenu
|
||||||
to the \gui Edit Menu using QMenu's \l
|
to the \uicontrol Edit Menu using QMenu's \l
|
||||||
{QMenu::addMenu()}{addMenu()} function. Secondly, take a look at the
|
{QMenu::addMenu()}{addMenu()} function. Secondly, take a look at the
|
||||||
alignment actions: In the \c createActions() function we added the
|
alignment actions: In the \c createActions() function we added the
|
||||||
\c leftAlignAct, \c rightAlignAct, \c justifyAct and \c centerAct
|
\c leftAlignAct, \c rightAlignAct, \c justifyAct and \c centerAct
|
||||||
@ -208,7 +208,7 @@
|
|||||||
ignores these events).
|
ignores these events).
|
||||||
|
|
||||||
Whenever we receive such an event, we create a menu containing the
|
Whenever we receive such an event, we create a menu containing the
|
||||||
\gui Cut, \gui Copy and \gui Paste actions. Context menus can be
|
\uicontrol Cut, \uicontrol Copy and \uicontrol Paste actions. Context menus can be
|
||||||
executed either asynchronously using the \l {QMenu::}{popup()}
|
executed either asynchronously using the \l {QMenu::}{popup()}
|
||||||
function or synchronously using the \l {QMenu::}{exec()}
|
function or synchronously using the \l {QMenu::}{exec()}
|
||||||
function. In this example, we have chosen to show the menu using
|
function. In this example, we have chosen to show the menu using
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
and their respective labels. The label for \c offersCheckBox is set and the
|
and their respective labels. The label for \c offersCheckBox is set and the
|
||||||
\c setupItemsTable() function is invoked to setup and populate
|
\c setupItemsTable() function is invoked to setup and populate
|
||||||
\c itemsTable. The QDialogButtonBox object, \c buttonBox, is instantiated
|
\c itemsTable. The QDialogButtonBox object, \c buttonBox, is instantiated
|
||||||
with \gui OK and \gui Cancel buttons. This \c buttonBox's \c accepted() and
|
with \uicontrol OK and \uicontrol Cancel buttons. This \c buttonBox's \c accepted() and
|
||||||
\c rejected() signals are connected to the \c verify() and \c reject()
|
\c rejected() signals are connected to the \c verify() and \c reject()
|
||||||
slots in \c DetailsDialog.
|
slots in \c DetailsDialog.
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@
|
|||||||
We return (1, 1) as the size hint for a header item. If we
|
We return (1, 1) as the size hint for a header item. If we
|
||||||
didn't, the headers would default to a larger size, preventing
|
didn't, the headers would default to a larger size, preventing
|
||||||
us from displaying really small items (which can be specified
|
us from displaying really small items (which can be specified
|
||||||
using the \gui{Pixel size} combobox).
|
using the \uicontrol{Pixel size} combobox).
|
||||||
|
|
||||||
\section1 PixelDelegate Class Definition
|
\section1 PixelDelegate Class Definition
|
||||||
|
|
||||||
@ -221,7 +221,7 @@
|
|||||||
We also set the minimum section size to 1 on the headers. If we
|
We also set the minimum section size to 1 on the headers. If we
|
||||||
didn't, the headers would default to a larger size, preventing
|
didn't, the headers would default to a larger size, preventing
|
||||||
us from displaying really small items (which can be specified
|
us from displaying really small items (which can be specified
|
||||||
using the \gui{Pixel size} combobox).
|
using the \uicontrol{Pixel size} combobox).
|
||||||
|
|
||||||
The custom delegate is constructed with the main window as its parent, so
|
The custom delegate is constructed with the main window as its parent, so
|
||||||
that it will be deleted correctly later, and we set it on the table view.
|
that it will be deleted correctly later, and we set it on the table view.
|
||||||
@ -251,5 +251,5 @@
|
|||||||
\snippet examples/itemviews/pixelator/mainwindow.cpp 6
|
\snippet examples/itemviews/pixelator/mainwindow.cpp 6
|
||||||
|
|
||||||
We explicitly resize the columns and rows to match the
|
We explicitly resize the columns and rows to match the
|
||||||
\gui{Pixel size} combobox.
|
\uicontrol{Pixel size} combobox.
|
||||||
*/
|
*/
|
||||||
|
@ -147,8 +147,8 @@
|
|||||||
\snippet examples/tools/plugandpaint/mainwindow.cpp 4
|
\snippet examples/tools/plugandpaint/mainwindow.cpp 4
|
||||||
|
|
||||||
The \c loadPlugins() function is called from the \c MainWindow
|
The \c loadPlugins() function is called from the \c MainWindow
|
||||||
constructor to detect plugins and update the \gui{Brush},
|
constructor to detect plugins and update the \uicontrol{Brush},
|
||||||
\gui{Shapes}, and \gui{Filters} menus. We start by handling static
|
\uicontrol{Shapes}, and \uicontrol{Filters} menus. We start by handling static
|
||||||
plugins (available through QPluginLoader::staticInstances())
|
plugins (available through QPluginLoader::staticInstances())
|
||||||
|
|
||||||
To the application that uses the plugin, a Qt plugin is simply a
|
To the application that uses the plugin, a Qt plugin is simply a
|
||||||
@ -183,8 +183,8 @@
|
|||||||
|
|
||||||
\snippet examples/tools/plugandpaint/mainwindow.cpp 9
|
\snippet examples/tools/plugandpaint/mainwindow.cpp 9
|
||||||
|
|
||||||
At the end, we enable or disable the \gui{Brush}, \gui{Shapes},
|
At the end, we enable or disable the \uicontrol{Brush}, \uicontrol{Shapes},
|
||||||
and \gui{Filters} menus based on whether they contain any items.
|
and \uicontrol{Filters} menus based on whether they contain any items.
|
||||||
|
|
||||||
\snippet examples/tools/plugandpaint/mainwindow.cpp 10
|
\snippet examples/tools/plugandpaint/mainwindow.cpp 10
|
||||||
|
|
||||||
@ -198,7 +198,7 @@
|
|||||||
\snippet examples/tools/plugandpaint/mainwindow.cpp 3
|
\snippet examples/tools/plugandpaint/mainwindow.cpp 3
|
||||||
|
|
||||||
The \c aboutPlugins() slot is called on startup and can be
|
The \c aboutPlugins() slot is called on startup and can be
|
||||||
invoked at any time through the \gui{About Plugins} action. It
|
invoked at any time through the \uicontrol{About Plugins} action. It
|
||||||
pops up a \c PluginDialog, providing information about the loaded
|
pops up a \c PluginDialog, providing information about the loaded
|
||||||
plugins.
|
plugins.
|
||||||
|
|
||||||
@ -214,7 +214,7 @@
|
|||||||
\snippet examples/tools/plugandpaint/mainwindow.cpp 0
|
\snippet examples/tools/plugandpaint/mainwindow.cpp 0
|
||||||
|
|
||||||
The \c changeBrush() slot is invoked when the user chooses one of
|
The \c changeBrush() slot is invoked when the user chooses one of
|
||||||
the brushes from the \gui{Brush} menu. We start by finding out
|
the brushes from the \uicontrol{Brush} menu. We start by finding out
|
||||||
which action invoked the slot using QObject::sender(). Then we
|
which action invoked the slot using QObject::sender(). Then we
|
||||||
get the \c BrushInterface out of the plugin (which we
|
get the \c BrushInterface out of the plugin (which we
|
||||||
conveniently passed as the QAction's parent) and we call \c
|
conveniently passed as the QAction's parent) and we call \c
|
||||||
@ -225,7 +225,7 @@
|
|||||||
\snippet examples/tools/plugandpaint/mainwindow.cpp 1
|
\snippet examples/tools/plugandpaint/mainwindow.cpp 1
|
||||||
|
|
||||||
The \c insertShape() is invoked when the use chooses one of the
|
The \c insertShape() is invoked when the use chooses one of the
|
||||||
shapes from the \gui{Shapes} menu. We retrieve the QAction that
|
shapes from the \uicontrol{Shapes} menu. We retrieve the QAction that
|
||||||
invoked the slot, then the \c ShapeInterface associated with that
|
invoked the slot, then the \c ShapeInterface associated with that
|
||||||
QAction, and finally we call \c ShapeInterface::generateShape()
|
QAction, and finally we call \c ShapeInterface::generateShape()
|
||||||
to obtain a QPainterPath.
|
to obtain a QPainterPath.
|
||||||
@ -359,8 +359,8 @@
|
|||||||
\snippet examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp 0
|
\snippet examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp 0
|
||||||
|
|
||||||
The \c brushes() function returns a list of brushes provided by
|
The \c brushes() function returns a list of brushes provided by
|
||||||
this plugin. We provide three brushes: \gui{Pencil}, \gui{Air
|
this plugin. We provide three brushes: \uicontrol{Pencil}, \uicontrol{Air
|
||||||
Brush}, and \gui{Random Letters}.
|
Brush}, and \uicontrol{Random Letters}.
|
||||||
|
|
||||||
\snippet examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp 1
|
\snippet examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp 1
|
||||||
|
|
||||||
@ -377,15 +377,15 @@
|
|||||||
Then comes the brush-dependent part of the code:
|
Then comes the brush-dependent part of the code:
|
||||||
|
|
||||||
\list
|
\list
|
||||||
\li If the brush is \gui{Pencil}, we just call
|
\li If the brush is \uicontrol{Pencil}, we just call
|
||||||
QPainter::drawLine() with the current QPen.
|
QPainter::drawLine() with the current QPen.
|
||||||
|
|
||||||
\li If the brush is \gui{Air Brush}, we start by setting the
|
\li If the brush is \uicontrol{Air Brush}, we start by setting the
|
||||||
painter's QBrush to Qt::Dense6Pattern to obtain a dotted
|
painter's QBrush to Qt::Dense6Pattern to obtain a dotted
|
||||||
pattern. Then we draw a circle filled with that QBrush several
|
pattern. Then we draw a circle filled with that QBrush several
|
||||||
times, resulting in a thick line.
|
times, resulting in a thick line.
|
||||||
|
|
||||||
\li If the brush is \gui{Random Letters}, we draw a random letter
|
\li If the brush is \uicontrol{Random Letters}, we draw a random letter
|
||||||
at the new cursor position. Most of the code is for setting
|
at the new cursor position. Most of the code is for setting
|
||||||
the font to be bold and larger than the default font and for
|
the font to be bold and larger than the default font and for
|
||||||
computing an appropriate bounding rect.
|
computing an appropriate bounding rect.
|
||||||
@ -403,8 +403,8 @@
|
|||||||
|
|
||||||
\snippet examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp 5
|
\snippet examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp 5
|
||||||
|
|
||||||
The plugin provides three shapes: \gui{Circle}, \gui{Star}, and
|
The plugin provides three shapes: \uicontrol{Circle}, \uicontrol{Star}, and
|
||||||
\gui{Text...}. The three dots after \gui{Text} are there because
|
\uicontrol{Text...}. The three dots after \uicontrol{Text} are there because
|
||||||
the shape pops up a dialog asking for more information. We know
|
the shape pops up a dialog asking for more information. We know
|
||||||
that the shape names will end up in a menu, so we include the
|
that the shape names will end up in a menu, so we include the
|
||||||
three dots in the shape name.
|
three dots in the shape name.
|
||||||
@ -416,15 +416,15 @@
|
|||||||
\snippet examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp 6
|
\snippet examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp 6
|
||||||
|
|
||||||
The \c generateShape() creates a QPainterPath for the specified
|
The \c generateShape() creates a QPainterPath for the specified
|
||||||
shape. If the shape is \gui{Text}, we pop up a QInputDialog to
|
shape. If the shape is \uicontrol{Text}, we pop up a QInputDialog to
|
||||||
let the user enter some text.
|
let the user enter some text.
|
||||||
|
|
||||||
\section1 Implementation of the Filter Interface
|
\section1 Implementation of the Filter Interface
|
||||||
|
|
||||||
\snippet examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp 7
|
\snippet examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp 7
|
||||||
|
|
||||||
The plugin provides three filters: \gui{Invert Pixels}, \gui{Swap
|
The plugin provides three filters: \uicontrol{Invert Pixels}, \uicontrol{Swap
|
||||||
RGB}, and \gui{Grayscale}.
|
RGB}, and \uicontrol{Grayscale}.
|
||||||
|
|
||||||
\snippet examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp 8
|
\snippet examples/tools/plugandpaintplugins/basictools/basictoolsplugin.cpp 8
|
||||||
|
|
||||||
@ -433,7 +433,7 @@
|
|||||||
is to convert the image to a 32-bit RGB format, to ensure that
|
is to convert the image to a 32-bit RGB format, to ensure that
|
||||||
the algorithms will work as expected. For example,
|
the algorithms will work as expected. For example,
|
||||||
QImage::invertPixels(), which is used to implement the
|
QImage::invertPixels(), which is used to implement the
|
||||||
\gui{Invert Pixels} filter, gives counterintuitive results for
|
\uicontrol{Invert Pixels} filter, gives counterintuitive results for
|
||||||
8-bit images, because they invert the indices into the color
|
8-bit images, because they invert the indices into the color
|
||||||
table instead of inverting the color table's entries.
|
table instead of inverting the color table's entries.
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
\li The \c saveScreenshot() slot saves the last screenshot.
|
\li The \c saveScreenshot() slot saves the last screenshot.
|
||||||
\li The \c shootScreen() slot takes the screenshot.
|
\li The \c shootScreen() slot takes the screenshot.
|
||||||
\li The \c updateCheckBox() slot enables or disables the
|
\li The \c updateCheckBox() slot enables or disables the
|
||||||
\gui {Hide This Window} option.
|
\uicontrol {Hide This Window} option.
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
We also declare some private functions: We use the \c
|
We also declare some private functions: We use the \c
|
||||||
@ -127,8 +127,8 @@
|
|||||||
requests a new screenshot; but the slot only prepares a new
|
requests a new screenshot; but the slot only prepares a new
|
||||||
screenshot.
|
screenshot.
|
||||||
|
|
||||||
First we see if the \gui {Hide This Window} option is checked, if
|
First we see if the \uicontrol {Hide This Window} option is checked, if
|
||||||
it is we hide the \c Screenshot widget. Then we disable the \gui
|
it is we hide the \c Screenshot widget. Then we disable the \uicontrol
|
||||||
{New Screenshot} button, to make sure the user only can request
|
{New Screenshot} button, to make sure the user only can request
|
||||||
one screenshot at a time.
|
one screenshot at a time.
|
||||||
|
|
||||||
@ -136,12 +136,12 @@
|
|||||||
and single-shot timers. We set the timer to time out only once,
|
and single-shot timers. We set the timer to time out only once,
|
||||||
using the static QTimer::singleShot() function. This function
|
using the static QTimer::singleShot() function. This function
|
||||||
calls the private \c shootScreen() slot after the time interval
|
calls the private \c shootScreen() slot after the time interval
|
||||||
specified by the \gui {Screenshot Delay} option. It is \c
|
specified by the \uicontrol {Screenshot Delay} option. It is \c
|
||||||
shootScreen() that actually performs the screenshot.
|
shootScreen() that actually performs the screenshot.
|
||||||
|
|
||||||
\snippet examples/desktop/screenshot/screenshot.cpp 3
|
\snippet examples/desktop/screenshot/screenshot.cpp 3
|
||||||
|
|
||||||
The \c saveScreenshot() slot is called when the user push the \gui
|
The \c saveScreenshot() slot is called when the user push the \uicontrol
|
||||||
Save button, and it presents a file dialog using the QFileDialog
|
Save button, and it presents a file dialog using the QFileDialog
|
||||||
class.
|
class.
|
||||||
|
|
||||||
@ -184,19 +184,19 @@
|
|||||||
QWidget::winID().
|
QWidget::winID().
|
||||||
|
|
||||||
We update the screenshot preview label using the private \c
|
We update the screenshot preview label using the private \c
|
||||||
updateScreenshotLabel() function. Then we enable the \gui {New
|
updateScreenshotLabel() function. Then we enable the \uicontrol {New
|
||||||
Screenshot} button, and finally we make the \c Screenshot widget
|
Screenshot} button, and finally we make the \c Screenshot widget
|
||||||
visible if it was hidden during the screenshot.
|
visible if it was hidden during the screenshot.
|
||||||
|
|
||||||
\snippet examples/desktop/screenshot/screenshot.cpp 6
|
\snippet examples/desktop/screenshot/screenshot.cpp 6
|
||||||
|
|
||||||
The \gui {Hide This Window} option is enabled or disabled
|
The \uicontrol {Hide This Window} option is enabled or disabled
|
||||||
depending on the delay of the screenshot. If there is no delay,
|
depending on the delay of the screenshot. If there is no delay,
|
||||||
the application window cannot be hidden and the option's checkbox
|
the application window cannot be hidden and the option's checkbox
|
||||||
is disabled.
|
is disabled.
|
||||||
|
|
||||||
The \c updateCheckBox() slot is called whenever the user changes
|
The \c updateCheckBox() slot is called whenever the user changes
|
||||||
the delay using the \gui {Screenshot Delay} option.
|
the delay using the \uicontrol {Screenshot Delay} option.
|
||||||
|
|
||||||
\snippet examples/desktop/screenshot/screenshot.cpp 7
|
\snippet examples/desktop/screenshot/screenshot.cpp 7
|
||||||
|
|
||||||
@ -204,9 +204,9 @@
|
|||||||
constructor.
|
constructor.
|
||||||
|
|
||||||
First we create a group box that will contain all of the options'
|
First we create a group box that will contain all of the options'
|
||||||
widgets. Then we create a QSpinBox and a QLabel for the \gui
|
widgets. Then we create a QSpinBox and a QLabel for the \uicontrol
|
||||||
{Screenshot Delay} option, and connect the spinbox to the \c
|
{Screenshot Delay} option, and connect the spinbox to the \c
|
||||||
updateCheckBox() slot. Finally, we create a QCheckBox for the \gui
|
updateCheckBox() slot. Finally, we create a QCheckBox for the \uicontrol
|
||||||
{Hide This Window} option, add all the options' widgets to a
|
{Hide This Window} option, add all the options' widgets to a
|
||||||
QGridLayout and install the layout on the group box.
|
QGridLayout and install the layout on the group box.
|
||||||
|
|
||||||
|
@ -45,11 +45,11 @@
|
|||||||
\image scribble-example.png Screenshot of the Scribble example
|
\image scribble-example.png Screenshot of the Scribble example
|
||||||
|
|
||||||
With the Scribble application the users can draw an image. The
|
With the Scribble application the users can draw an image. The
|
||||||
\gui File menu gives the users the possibility to open and edit an
|
\uicontrol File menu gives the users the possibility to open and edit an
|
||||||
existing image file, save an image and exit the application. While
|
existing image file, save an image and exit the application. While
|
||||||
drawing, the \gui Options menu allows the users to to choose the
|
drawing, the \uicontrol Options menu allows the users to to choose the
|
||||||
pen color and pen width, as well as clear the screen. In addition
|
pen color and pen width, as well as clear the screen. In addition
|
||||||
the \gui Help menu provides the users with information about the
|
the \uicontrol Help menu provides the users with information about the
|
||||||
Scribble example in particular, and about Qt in general.
|
Scribble example in particular, and about Qt in general.
|
||||||
|
|
||||||
The example consists of two classes:
|
The example consists of two classes:
|
||||||
@ -266,7 +266,7 @@
|
|||||||
We use the boolean \c maybeSave() function to check if there are
|
We use the boolean \c maybeSave() function to check if there are
|
||||||
any unsaved changes. If there are unsaved changes, we give the
|
any unsaved changes. If there are unsaved changes, we give the
|
||||||
user the opportunity to save these changes. The function returns
|
user the opportunity to save these changes. The function returns
|
||||||
\c false if the user clicks \gui Cancel. We use the \c saveFile()
|
\c false if the user clicks \uicontrol Cancel. We use the \c saveFile()
|
||||||
function to let the user save the image currently displayed in
|
function to let the user save the image currently displayed in
|
||||||
the scribble area.
|
the scribble area.
|
||||||
|
|
||||||
@ -282,7 +282,7 @@
|
|||||||
\snippet examples/widgets/scribble/mainwindow.cpp 2
|
\snippet examples/widgets/scribble/mainwindow.cpp 2
|
||||||
|
|
||||||
Close events are sent to widgets that the users want to close,
|
Close events are sent to widgets that the users want to close,
|
||||||
usually by clicking \gui{File|Exit} or by clicking the \gui X
|
usually by clicking \uicontrol{File|Exit} or by clicking the \uicontrol X
|
||||||
title bar button. By reimplementing the event handler, we can
|
title bar button. By reimplementing the event handler, we can
|
||||||
intercept attempts to close the application.
|
intercept attempts to close the application.
|
||||||
|
|
||||||
@ -291,7 +291,7 @@
|
|||||||
maybeSave() function. If \c maybeSave() returns true, there are
|
maybeSave() function. If \c maybeSave() returns true, there are
|
||||||
no modifications or the users successfully saved them, and we
|
no modifications or the users successfully saved them, and we
|
||||||
accept the event. The application can then terminate normally. If
|
accept the event. The application can then terminate normally. If
|
||||||
\c maybeSave() returns false, the user clicked \gui Cancel, so we
|
\c maybeSave() returns false, the user clicked \uicontrol Cancel, so we
|
||||||
"ignore" the event, leaving the application unaffected by it.
|
"ignore" the event, leaving the application unaffected by it.
|
||||||
|
|
||||||
\snippet examples/widgets/scribble/mainwindow.cpp 3
|
\snippet examples/widgets/scribble/mainwindow.cpp 3
|
||||||
@ -305,7 +305,7 @@
|
|||||||
\snippet examples/widgets/scribble/mainwindow.cpp 5
|
\snippet examples/widgets/scribble/mainwindow.cpp 5
|
||||||
\snippet examples/widgets/scribble/mainwindow.cpp 6
|
\snippet examples/widgets/scribble/mainwindow.cpp 6
|
||||||
|
|
||||||
The \c save() slot is called when the users choose the \gui {Save
|
The \c save() slot is called when the users choose the \uicontrol {Save
|
||||||
As} menu entry, and then choose an entry from the format menu. The
|
As} menu entry, and then choose an entry from the format menu. The
|
||||||
first thing we need to do is to find out which action sent the
|
first thing we need to do is to find out which action sent the
|
||||||
signal using QObject::sender(). This function returns the sender
|
signal using QObject::sender(). This function returns the sender
|
||||||
@ -346,7 +346,7 @@
|
|||||||
value by 1).
|
value by 1).
|
||||||
|
|
||||||
The boolean \c ok variable will be set to \c true if the user
|
The boolean \c ok variable will be set to \c true if the user
|
||||||
clicked \gui OK and to \c false if the user pressed \gui Cancel.
|
clicked \uicontrol OK and to \c false if the user pressed \uicontrol Cancel.
|
||||||
|
|
||||||
\snippet examples/widgets/scribble/mainwindow.cpp 11
|
\snippet examples/widgets/scribble/mainwindow.cpp 11
|
||||||
\snippet examples/widgets/scribble/mainwindow.cpp 12
|
\snippet examples/widgets/scribble/mainwindow.cpp 12
|
||||||
@ -359,7 +359,7 @@
|
|||||||
|
|
||||||
In the \c createAction() function we create the actions
|
In the \c createAction() function we create the actions
|
||||||
representing the menu entries and connect them to the appropriate
|
representing the menu entries and connect them to the appropriate
|
||||||
slots. In particular we create the actions found in the \gui
|
slots. In particular we create the actions found in the \uicontrol
|
||||||
{Save As} sub-menu. We use QImageWriter::supportedImageFormats()
|
{Save As} sub-menu. We use QImageWriter::supportedImageFormats()
|
||||||
to get a list of the supported formats (as a QList<QByteArray>).
|
to get a list of the supported formats (as a QList<QByteArray>).
|
||||||
|
|
||||||
@ -374,13 +374,13 @@
|
|||||||
|
|
||||||
In the \c createMenu() function, we add the previously created
|
In the \c createMenu() function, we add the previously created
|
||||||
format actions to the \c saveAsMenu. Then we add the rest of the
|
format actions to the \c saveAsMenu. Then we add the rest of the
|
||||||
actions as well as the \c saveAsMenu sub-menu to the \gui File,
|
actions as well as the \c saveAsMenu sub-menu to the \uicontrol File,
|
||||||
\gui Options and \gui Help menus.
|
\uicontrol Options and \uicontrol Help menus.
|
||||||
|
|
||||||
The QMenu class provides a menu widget for use in menu bars,
|
The QMenu class provides a menu widget for use in menu bars,
|
||||||
context menus, and other popup menus. The QMenuBar class provides
|
context menus, and other popup menus. The QMenuBar class provides
|
||||||
a horizontal menu bar with a list of pull-down \l{QMenu}s. At the
|
a horizontal menu bar with a list of pull-down \l{QMenu}s. At the
|
||||||
end we put the \gui File and \gui Options menus in the \c
|
end we put the \uicontrol File and \uicontrol Options menus in the \c
|
||||||
{MainWindow}'s menu bar, which we retrieve using the
|
{MainWindow}'s menu bar, which we retrieve using the
|
||||||
QMainWindow::menuBar() function.
|
QMainWindow::menuBar() function.
|
||||||
|
|
||||||
@ -401,11 +401,11 @@
|
|||||||
|
|
||||||
If the user chooses to save, we call the private \c saveFile()
|
If the user chooses to save, we call the private \c saveFile()
|
||||||
function. For simplicitly, we use PNG as the file format; the
|
function. For simplicitly, we use PNG as the file format; the
|
||||||
user can always press \gui Cancel and save the file using another
|
user can always press \uicontrol Cancel and save the file using another
|
||||||
format.
|
format.
|
||||||
|
|
||||||
The \c maybeSave() function returns \c false if the user clicks
|
The \c maybeSave() function returns \c false if the user clicks
|
||||||
\gui Cancel; otherwise it returns \c true.
|
\uicontrol Cancel; otherwise it returns \c true.
|
||||||
|
|
||||||
\snippet examples/widgets/scribble/mainwindow.cpp 19
|
\snippet examples/widgets/scribble/mainwindow.cpp 19
|
||||||
\snippet examples/widgets/scribble/mainwindow.cpp 20
|
\snippet examples/widgets/scribble/mainwindow.cpp 20
|
||||||
|
@ -40,8 +40,8 @@
|
|||||||
allowing specially-shaped windows to be created. In this example, we use this feature
|
allowing specially-shaped windows to be created. In this example, we use this feature
|
||||||
to create a circular window containing an analog clock.
|
to create a circular window containing an analog clock.
|
||||||
|
|
||||||
Since this example's window does not provide a \gui File menu or a close
|
Since this example's window does not provide a \uicontrol File menu or a close
|
||||||
button, we provide a context menu with an \gui Exit entry so that the example
|
button, we provide a context menu with an \uicontrol Exit entry so that the example
|
||||||
can be closed. Click the right mouse button over the window to open this menu.
|
can be closed. Click the right mouse button over the window to open this menu.
|
||||||
|
|
||||||
\section1 ShapedClock Class Definition
|
\section1 ShapedClock Class Definition
|
||||||
|
@ -72,7 +72,7 @@
|
|||||||
|
|
||||||
\snippet examples/itemviews/simplewidgetmapper/window.cpp Set up the mapper
|
\snippet examples/itemviews/simplewidgetmapper/window.cpp Set up the mapper
|
||||||
|
|
||||||
We also connect the mapper to the \gui{Next} and \gui{Previous} buttons
|
We also connect the mapper to the \uicontrol{Next} and \uicontrol{Previous} buttons
|
||||||
via its \l{QDataWidgetMapper::}{toNext()} and
|
via its \l{QDataWidgetMapper::}{toNext()} and
|
||||||
\l{QDataWidgetMapper::}{toPrevious()} slots. The mapper's
|
\l{QDataWidgetMapper::}{toPrevious()} slots. The mapper's
|
||||||
\l{QDataWidgetMapper::}{currentIndexChanged()} signal is connected to the
|
\l{QDataWidgetMapper::}{currentIndexChanged()} signal is connected to the
|
||||||
@ -106,8 +106,8 @@
|
|||||||
|
|
||||||
\snippet examples/itemviews/simplewidgetmapper/window.cpp Slot for updating the buttons
|
\snippet examples/itemviews/simplewidgetmapper/window.cpp Slot for updating the buttons
|
||||||
|
|
||||||
If the mapper is referring to the first row in the model, the \gui{Previous}
|
If the mapper is referring to the first row in the model, the \uicontrol{Previous}
|
||||||
button is disabled. Similarly, the \gui{Next} button is disabled if the
|
button is disabled. Similarly, the \uicontrol{Next} button is disabled if the
|
||||||
mapper reaches the last row in the model.
|
mapper reaches the last row in the model.
|
||||||
|
|
||||||
\section1 More Complex Mappings
|
\section1 More Complex Mappings
|
||||||
|
@ -144,18 +144,18 @@
|
|||||||
toward the slider's minimum. This can be useful if the \e
|
toward the slider's minimum. This can be useful if the \e
|
||||||
appearance of a slider is inverted: Some users might expect the
|
appearance of a slider is inverted: Some users might expect the
|
||||||
keys to still work the same way on the value, whereas others
|
keys to still work the same way on the value, whereas others
|
||||||
might expect \key PageUp to mean "up" on the screen.
|
might expect \uicontrol PageUp to mean "up" on the screen.
|
||||||
|
|
||||||
Note that for horizontal and vertical scroll bars, the key
|
Note that for horizontal and vertical scroll bars, the key
|
||||||
bindings are inverted by default: \key PageDown increases the
|
bindings are inverted by default: \uicontrol PageDown increases the
|
||||||
current value, and \key PageUp decreases it.
|
current value, and \uicontrol PageUp decreases it.
|
||||||
|
|
||||||
\snippet examples/widgets/sliders/window.cpp 5
|
\snippet examples/widgets/sliders/window.cpp 5
|
||||||
\snippet examples/widgets/sliders/window.cpp 6
|
\snippet examples/widgets/sliders/window.cpp 6
|
||||||
|
|
||||||
Then we create the spin boxes. QSpinBox allows the user to choose
|
Then we create the spin boxes. QSpinBox allows the user to choose
|
||||||
a value by clicking the up and down buttons or pressing the \key
|
a value by clicking the up and down buttons or pressing the \key
|
||||||
Up and \key Down keys on the keyboard to modify the value
|
Up and \uicontrol Down keys on the keyboard to modify the value
|
||||||
currently displayed. The user can also type in the value
|
currently displayed. The user can also type in the value
|
||||||
manually. The spin boxes control the minimum, maximum and current
|
manually. The spin boxes control the minimum, maximum and current
|
||||||
values for the QSlider, QScrollBar, and QDial widgets.
|
values for the QSlider, QScrollBar, and QDial widgets.
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
|
|
||||||
The first spin box shows the simplest way to use QSpinBox. It accepts values
|
The first spin box shows the simplest way to use QSpinBox. It accepts values
|
||||||
from -20 to 20, the current value can be increased or decreased by 1 with
|
from -20 to 20, the current value can be increased or decreased by 1 with
|
||||||
either the arrow buttons or \key{Up} and \key{Down} keys, and the default
|
either the arrow buttons or \uicontrol{Up} and \uicontrol{Down} keys, and the default
|
||||||
value is 0.
|
value is 0.
|
||||||
|
|
||||||
The second spin box uses a larger step size and displays a suffix to
|
The second spin box uses a larger step size and displays a suffix to
|
||||||
@ -77,8 +77,8 @@
|
|||||||
|
|
||||||
This spin box also displays a
|
This spin box also displays a
|
||||||
\l{QAbstractSpinBox::specialValueText}{special value} instead of the minimum
|
\l{QAbstractSpinBox::specialValueText}{special value} instead of the minimum
|
||||||
value defined for it. This means that it will never show \gui{0%}, but will
|
value defined for it. This means that it will never show \uicontrol{0%}, but will
|
||||||
display \gui{Automatic} when the minimum value is selected.
|
display \uicontrol{Automatic} when the minimum value is selected.
|
||||||
|
|
||||||
The third spin box shows how a prefix can be used:
|
The third spin box shows how a prefix can be used:
|
||||||
|
|
||||||
@ -99,7 +99,7 @@
|
|||||||
|
|
||||||
The first spin box is a QDateEdit widget that is able to accept dates
|
The first spin box is a QDateEdit widget that is able to accept dates
|
||||||
within a given range specified using QDate values. The arrow buttons and
|
within a given range specified using QDate values. The arrow buttons and
|
||||||
\key{Up} and \key{Down} keys can be used to increase and decrease the
|
\uicontrol{Up} and \uicontrol{Down} keys can be used to increase and decrease the
|
||||||
values for year, month, and day when the cursor is in the relevant section.
|
values for year, month, and day when the cursor is in the relevant section.
|
||||||
|
|
||||||
The second spin box is a QTimeEdit widget:
|
The second spin box is a QTimeEdit widget:
|
||||||
|
@ -405,7 +405,7 @@
|
|||||||
|
|
||||||
\snippet examples/widgets/styles/widgetgallery.cpp 0
|
\snippet examples/widgets/styles/widgetgallery.cpp 0
|
||||||
|
|
||||||
We start by creating child widgets. The \gui Style combobox is
|
We start by creating child widgets. The \uicontrol Style combobox is
|
||||||
initialized with all the styles known to QStyleFactory, in
|
initialized with all the styles known to QStyleFactory, in
|
||||||
addition to \c NorwegianWood. The \c create...() functions are
|
addition to \c NorwegianWood. The \c create...() functions are
|
||||||
private functions that set up the various parts of the \c
|
private functions that set up the various parts of the \c
|
||||||
@ -414,9 +414,9 @@
|
|||||||
\snippet examples/widgets/styles/widgetgallery.cpp 1
|
\snippet examples/widgets/styles/widgetgallery.cpp 1
|
||||||
\snippet examples/widgets/styles/widgetgallery.cpp 2
|
\snippet examples/widgets/styles/widgetgallery.cpp 2
|
||||||
|
|
||||||
We connect the \gui Style combobox to the \c changeStyle()
|
We connect the \uicontrol Style combobox to the \c changeStyle()
|
||||||
private slot, the \gui{Use style's standard palette} check box to
|
private slot, the \uicontrol{Use style's standard palette} check box to
|
||||||
the \c changePalette() slot, and the \gui{Disable widgets} check
|
the \c changePalette() slot, and the \uicontrol{Disable widgets} check
|
||||||
box to the child widgets'
|
box to the child widgets'
|
||||||
\l{QWidget::setDisabled()}{setDisabled()} slot.
|
\l{QWidget::setDisabled()}{setDisabled()} slot.
|
||||||
|
|
||||||
@ -435,7 +435,7 @@
|
|||||||
\snippet examples/widgets/styles/widgetgallery.cpp 7
|
\snippet examples/widgets/styles/widgetgallery.cpp 7
|
||||||
\snippet examples/widgets/styles/widgetgallery.cpp 8
|
\snippet examples/widgets/styles/widgetgallery.cpp 8
|
||||||
|
|
||||||
If the user turns the \gui{Use style's standard palette} on, the
|
If the user turns the \uicontrol{Use style's standard palette} on, the
|
||||||
current style's \l{QStyle::standardPalette()}{standard palette}
|
current style's \l{QStyle::standardPalette()}{standard palette}
|
||||||
is used; otherwise, the system's default palette is honored.
|
is used; otherwise, the system's default palette is honored.
|
||||||
|
|
||||||
|
@ -41,13 +41,13 @@
|
|||||||
If more than one row is filled, the blocks on each row are removed, and the
|
If more than one row is filled, the blocks on each row are removed, and the
|
||||||
player earns extra points.
|
player earns extra points.
|
||||||
|
|
||||||
The \gui{Left} cursor key moves the current piece one space to the left, the
|
The \uicontrol{Left} cursor key moves the current piece one space to the left, the
|
||||||
\gui{Right} cursor key moves it one space to the right, the \gui{Up} cursor
|
\uicontrol{Right} cursor key moves it one space to the right, the \uicontrol{Up} cursor
|
||||||
key rotates the piece counter-clockwise by 90 degrees, and the \gui{Down}
|
key rotates the piece counter-clockwise by 90 degrees, and the \uicontrol{Down}
|
||||||
cursor key rotates the piece clockwise by 90 degrees.
|
cursor key rotates the piece clockwise by 90 degrees.
|
||||||
|
|
||||||
To avoid waiting for a piece to fall to the bottom of the board, press \gui{D}
|
To avoid waiting for a piece to fall to the bottom of the board, press \uicontrol{D}
|
||||||
to immediately move the piece down by one row, or press the \gui{Space} key to
|
to immediately move the piece down by one row, or press the \uicontrol{Space} key to
|
||||||
drop it as close to the bottom of the board as possible.
|
drop it as close to the bottom of the board as possible.
|
||||||
|
|
||||||
This example shows how a simple game can be created using only three classes:
|
This example shows how a simple game can be created using only three classes:
|
||||||
@ -104,10 +104,10 @@
|
|||||||
These buttons are configured so that they never receive the keyboard focus;
|
These buttons are configured so that they never receive the keyboard focus;
|
||||||
we want the keyboard focus to remain with the \c TetrixBoard instance so that
|
we want the keyboard focus to remain with the \c TetrixBoard instance so that
|
||||||
it receives all the keyboard events. Nonetheless, the buttons will still respond
|
it receives all the keyboard events. Nonetheless, the buttons will still respond
|
||||||
to \key{Alt} key shortcuts.
|
to \uicontrol{Alt} key shortcuts.
|
||||||
|
|
||||||
We connect \l{QAbstractButton::}{clicked()} signals from the \gui{Start}
|
We connect \l{QAbstractButton::}{clicked()} signals from the \uicontrol{Start}
|
||||||
and \gui{Pause} buttons to the board, and from the \gui{Quit} button to the
|
and \uicontrol{Pause} buttons to the board, and from the \uicontrol{Quit} button to the
|
||||||
application's \l{QApplication::}{quit()} slot.
|
application's \l{QApplication::}{quit()} slot.
|
||||||
|
|
||||||
\snippet examples/widgets/tetrix/tetrixwindow.cpp 4
|
\snippet examples/widgets/tetrix/tetrixwindow.cpp 4
|
||||||
@ -345,7 +345,7 @@
|
|||||||
\c pieceDropped() function so that the player's score can be updated.
|
\c pieceDropped() function so that the player's score can be updated.
|
||||||
|
|
||||||
The \c oneLineDown() function is used to move the current piece down by one row
|
The \c oneLineDown() function is used to move the current piece down by one row
|
||||||
(line), either when the user presses the \gui{D} key or when the piece is
|
(line), either when the user presses the \uicontrol{D} key or when the piece is
|
||||||
scheduled to move:
|
scheduled to move:
|
||||||
|
|
||||||
\snippet examples/widgets/tetrix/tetrixboard.cpp 21
|
\snippet examples/widgets/tetrix/tetrixboard.cpp 21
|
||||||
|
@ -287,7 +287,7 @@
|
|||||||
|
|
||||||
Then we create the \c RenderArea widgets that will render their
|
Then we create the \c RenderArea widgets that will render their
|
||||||
shapes with coordinate tranformations. By default the applied
|
shapes with coordinate tranformations. By default the applied
|
||||||
operation is \gui {No Transformation}, i.e. the shapes are
|
operation is \uicontrol {No Transformation}, i.e. the shapes are
|
||||||
rendered within the default coordinate system. We create and
|
rendered within the default coordinate system. We create and
|
||||||
initialize the associated \l {QComboBox}es with items
|
initialize the associated \l {QComboBox}es with items
|
||||||
corresponding to the various transformation operations decribed by
|
corresponding to the various transformation operations decribed by
|
||||||
|
@ -147,7 +147,7 @@
|
|||||||
are obsolete. This is because these texts appeared in \c tr() calls that
|
are obsolete. This is because these texts appeared in \c tr() calls that
|
||||||
have been replaced by new calls with two arguments. The second pair has
|
have been replaced by new calls with two arguments. The second pair has
|
||||||
"two-sided" as their comment, and the third pair has "colors" as their
|
"two-sided" as their comment, and the third pair has "colors" as their
|
||||||
comment. The comments are shown in the \gui {Source text and comments}
|
comment. The comments are shown in the \uicontrol {Source text and comments}
|
||||||
area in \e {Qt Linguist}.
|
area in \e {Qt Linguist}.
|
||||||
|
|
||||||
Second, the translation text "Ativado" and "Desativado" have been
|
Second, the translation text "Ativado" and "Desativado" have been
|
||||||
@ -184,7 +184,7 @@
|
|||||||
dialogs. You could also add them to the example files, e.g. \c
|
dialogs. You could also add them to the example files, e.g. \c
|
||||||
mainwindow.cpp and \c printpanel.cpp are appropriate files. Run \c
|
mainwindow.cpp and \c printpanel.cpp are appropriate files. Run \c
|
||||||
lupdate and then start \e {Qt Linguist} and load in \c trollprint_pt.ts.
|
lupdate and then start \e {Qt Linguist} and load in \c trollprint_pt.ts.
|
||||||
You should see the comments in the \gui {Source text and comments} area
|
You should see the comments in the \uicontrol {Source text and comments} area
|
||||||
as you browse through the list of source texts.
|
as you browse through the list of source texts.
|
||||||
|
|
||||||
Sometimes, particularly with large programs, it can be difficult for
|
Sometimes, particularly with large programs, it can be difficult for
|
||||||
@ -241,7 +241,7 @@
|
|||||||
|
|
||||||
Go over the translations in \c MainWindow and mark these as "done".
|
Go over the translations in \c MainWindow and mark these as "done".
|
||||||
Translate "\<b\>TROLL PRINT\</b\>" as "\<b\>TROLL IMPRIMIR\</b\>".
|
Translate "\<b\>TROLL PRINT\</b\>" as "\<b\>TROLL IMPRIMIR\</b\>".
|
||||||
When you're translating "Two-sided", press the \gui {Guess Again}
|
When you're translating "Two-sided", press the \uicontrol {Guess Again}
|
||||||
button to translate "Two-sided", but change the "2" into "Dois".
|
button to translate "Two-sided", but change the "2" into "Dois".
|
||||||
|
|
||||||
Save and quit, then run \c lrelease. The Portuguese version
|
Save and quit, then run \c lrelease. The Portuguese version
|
||||||
@ -249,9 +249,9 @@
|
|||||||
|
|
||||||
\image linguist-trollprint_11_pt.png
|
\image linguist-trollprint_11_pt.png
|
||||||
|
|
||||||
Choose \gui{Ajuda|Sobre} (\gui{Help|About}) to see the about box.
|
Choose \uicontrol{Ajuda|Sobre} (\uicontrol{Help|About}) to see the about box.
|
||||||
|
|
||||||
If you choose \gui {Ajuda|Sobre Qt} (\gui {Help|About Qt}), you'll get
|
If you choose \uicontrol {Ajuda|Sobre Qt} (\uicontrol {Help|About Qt}), you'll get
|
||||||
an English dialog. Oops! Qt itself needs to be translated. See
|
an English dialog. Oops! Qt itself needs to be translated. See
|
||||||
\l{Internationalization with Qt} for details.
|
\l{Internationalization with Qt} for details.
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@
|
|||||||
In the constructor we first create the preview window. Then we
|
In the constructor we first create the preview window. Then we
|
||||||
create the group boxes containing the available window flags using
|
create the group boxes containing the available window flags using
|
||||||
the private \c createTypeGroupBox() and \c createHintsGroupBox()
|
the private \c createTypeGroupBox() and \c createHintsGroupBox()
|
||||||
functions. In addition we create a \gui Quit button. We put the
|
functions. In addition we create a \uicontrol Quit button. We put the
|
||||||
button and a stretchable space in a separate layout to make the
|
button and a stretchable space in a separate layout to make the
|
||||||
button appear in the \c WindowFlag widget's right bottom corner.
|
button appear in the \c WindowFlag widget's right bottom corner.
|
||||||
|
|
||||||
@ -181,7 +181,7 @@
|
|||||||
read-only text editor. It is also provided with a QPushbutton that
|
read-only text editor. It is also provided with a QPushbutton that
|
||||||
closes the window.
|
closes the window.
|
||||||
|
|
||||||
We reimplement the constructor to create the \gui Close button and
|
We reimplement the constructor to create the \uicontrol Close button and
|
||||||
the text editor, and the QWidget::setWindowFlags() function to
|
the text editor, and the QWidget::setWindowFlags() function to
|
||||||
display the names of the window flags.
|
display the names of the window flags.
|
||||||
|
|
||||||
@ -202,7 +202,7 @@
|
|||||||
breaks were guaranteed, using another QTextEdit::LineWrapMode
|
breaks were guaranteed, using another QTextEdit::LineWrapMode
|
||||||
would perhaps make more sense.
|
would perhaps make more sense.
|
||||||
|
|
||||||
Then we create the \gui Close button, and put both the widgets
|
Then we create the \uicontrol Close button, and put both the widgets
|
||||||
into a QVBoxLayout before we set the window title.
|
into a QVBoxLayout before we set the window title.
|
||||||
|
|
||||||
\snippet examples/widgets/windowflags/previewwindow.cpp 1
|
\snippet examples/widgets/windowflags/previewwindow.cpp 1
|
||||||
|
@ -843,7 +843,7 @@ QKeyEvent::~QKeyEvent()
|
|||||||
after the event occurred.
|
after the event occurred.
|
||||||
|
|
||||||
\warning This function cannot always be trusted. The user can
|
\warning This function cannot always be trusted. The user can
|
||||||
confuse it by pressing both \key{Shift} keys simultaneously and
|
confuse it by pressing both \uicontrol{Shift} keys simultaneously and
|
||||||
releasing one of them, for example.
|
releasing one of them, for example.
|
||||||
|
|
||||||
\sa QApplication::keyboardModifiers()
|
\sa QApplication::keyboardModifiers()
|
||||||
@ -952,7 +952,7 @@ bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
|
|||||||
|
|
||||||
Focus events are sent to widgets when the keyboard input focus
|
Focus events are sent to widgets when the keyboard input focus
|
||||||
changes. Focus events occur due to mouse actions, key presses
|
changes. Focus events occur due to mouse actions, key presses
|
||||||
(such as \gui{Tab} or \gui{Backtab}), the window system, popup
|
(such as \uicontrol{Tab} or \uicontrol{Backtab}), the window system, popup
|
||||||
menus, keyboard shortcuts, or other application-specific reasons.
|
menus, keyboard shortcuts, or other application-specific reasons.
|
||||||
The reason for a particular focus event is returned by reason()
|
The reason for a particular focus event is returned by reason()
|
||||||
in the appropriate event handler.
|
in the appropriate event handler.
|
||||||
@ -1198,7 +1198,7 @@ QResizeEvent::~QResizeEvent()
|
|||||||
|
|
||||||
Close events are sent to widgets that the user wants to close,
|
Close events are sent to widgets that the user wants to close,
|
||||||
usually by choosing "Close" from the window menu, or by clicking
|
usually by choosing "Close" from the window menu, or by clicking
|
||||||
the \gui{X} title bar button. They are also sent when you call
|
the \uicontrol{X} title bar button. They are also sent when you call
|
||||||
QWidget::close() to close a widget programmatically.
|
QWidget::close() to close a widget programmatically.
|
||||||
|
|
||||||
Close events contain a flag that indicates whether the receiver
|
Close events contain a flag that indicates whether the receiver
|
||||||
@ -1880,7 +1880,7 @@ QVariant QInputMethodQueryEvent::value(Qt::InputMethodQuery query) const
|
|||||||
x and y axes respectively.
|
x and y axes respectively.
|
||||||
|
|
||||||
\a keyState specifies which keyboard modifiers are pressed (e.g.,
|
\a keyState specifies which keyboard modifiers are pressed (e.g.,
|
||||||
\key{Ctrl}).
|
\uicontrol{Ctrl}).
|
||||||
|
|
||||||
The \a uniqueID parameter contains the unique ID for the current device.
|
The \a uniqueID parameter contains the unique ID for the current device.
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ void QOpenUrlHandlerRegistry::handlerDestroyed(QObject *handler)
|
|||||||
scheme to the default behavior.
|
scheme to the default behavior.
|
||||||
|
|
||||||
This system makes it easy to implement a help system, for example. Help could be
|
This system makes it easy to implement a help system, for example. Help could be
|
||||||
provided in labels and text browsers using \gui{help://myapplication/mytopic}
|
provided in labels and text browsers using \uicontrol{help://myapplication/mytopic}
|
||||||
URLs, and by registering a handler it becomes possible to display the help text
|
URLs, and by registering a handler it becomes possible to display the help text
|
||||||
inside the application:
|
inside the application:
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ void QAbstractPrintDialogPrivate::setPrinter(QPrinter *newPrinter)
|
|||||||
The printer dialog (shown above in Plastique style) enables access to common
|
The printer dialog (shown above in Plastique style) enables access to common
|
||||||
printing properties. On X11 platforms that use the CUPS printing system, the
|
printing properties. On X11 platforms that use the CUPS printing system, the
|
||||||
settings for each available printer can be modified via the dialog's
|
settings for each available printer can be modified via the dialog's
|
||||||
\gui{Properties} push button.
|
\uicontrol{Properties} push button.
|
||||||
|
|
||||||
On Windows and Mac OS X, the native print dialog is used, which means that
|
On Windows and Mac OS X, the native print dialog is used, which means that
|
||||||
some QWidget and QDialog properties set on the dialog won't be respected.
|
some QWidget and QDialog properties set on the dialog won't be respected.
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
|
|
||||||
Although QPrinter objects can be constructed and set up without requiring user
|
Although QPrinter objects can be constructed and set up without requiring user
|
||||||
input, printing is often performed as a result of a request by the user;
|
input, printing is often performed as a result of a request by the user;
|
||||||
for example, when the user selects the \gui{File|Print...} menu item in a GUI
|
for example, when the user selects the \uicontrol{File|Print...} menu item in a GUI
|
||||||
application. In such cases, a newly-constructed QPrinter object is supplied to
|
application. In such cases, a newly-constructed QPrinter object is supplied to
|
||||||
a QPrintDialog, allowing the user to specify the printer to use, paper size, and
|
a QPrintDialog, allowing the user to specify the printer to use, paper size, and
|
||||||
other printing properties.
|
other printing properties.
|
||||||
|
@ -649,33 +649,33 @@ void QMessageBoxPrivate::_q_buttonClicked(QAbstractButton *button)
|
|||||||
|
|
||||||
\section1 Default and Escape Keys
|
\section1 Default and Escape Keys
|
||||||
|
|
||||||
The default button (i.e., the button activated when \key Enter is
|
The default button (i.e., the button activated when \uicontrol Enter is
|
||||||
pressed) can be specified using setDefaultButton(). If a default
|
pressed) can be specified using setDefaultButton(). If a default
|
||||||
button is not specified, QMessageBox tries to find one based on
|
button is not specified, QMessageBox tries to find one based on
|
||||||
the \l{ButtonRole} {button roles} of the buttons used in the
|
the \l{ButtonRole} {button roles} of the buttons used in the
|
||||||
message box.
|
message box.
|
||||||
|
|
||||||
The escape button (the button activated when \key Esc is pressed)
|
The escape button (the button activated when \uicontrol Esc is pressed)
|
||||||
can be specified using setEscapeButton(). If an escape button is
|
can be specified using setEscapeButton(). If an escape button is
|
||||||
not specified, QMessageBox tries to find one using these rules:
|
not specified, QMessageBox tries to find one using these rules:
|
||||||
|
|
||||||
\list 1
|
\list 1
|
||||||
|
|
||||||
\li If there is only one button, it is the button activated when
|
\li If there is only one button, it is the button activated when
|
||||||
\key Esc is pressed.
|
\uicontrol Esc is pressed.
|
||||||
|
|
||||||
\li If there is a \l Cancel button, it is the button activated when
|
\li If there is a \l Cancel button, it is the button activated when
|
||||||
\key Esc is pressed.
|
\uicontrol Esc is pressed.
|
||||||
|
|
||||||
\li If there is exactly one button having either
|
\li If there is exactly one button having either
|
||||||
\l{QMessageBox::RejectRole} {the Reject role} or the
|
\l{QMessageBox::RejectRole} {the Reject role} or the
|
||||||
\l{QMessageBox::NoRole} {the No role}, it is the button
|
\l{QMessageBox::NoRole} {the No role}, it is the button
|
||||||
activated when \key Esc is pressed.
|
activated when \uicontrol Esc is pressed.
|
||||||
|
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
When an escape button can't be determined using these rules,
|
When an escape button can't be determined using these rules,
|
||||||
pressing \key Esc has no effect.
|
pressing \uicontrol Esc has no effect.
|
||||||
|
|
||||||
\sa QDialogButtonBox, {fowler}{GUI Design Handbook: Message Box}, {Standard Dialogs Example}, {Application Example}
|
\sa QDialogButtonBox, {fowler}{GUI Design Handbook: Message Box}, {Standard Dialogs Example}, {Application Example}
|
||||||
*/
|
*/
|
||||||
@ -932,7 +932,7 @@ QAbstractButton *QMessageBox::button(StandardButton which) const
|
|||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
When an escape button could not be automatically detected, pressing
|
When an escape button could not be automatically detected, pressing
|
||||||
\key Esc has no effect.
|
\uicontrol Esc has no effect.
|
||||||
|
|
||||||
\sa addButton()
|
\sa addButton()
|
||||||
*/
|
*/
|
||||||
@ -945,7 +945,7 @@ QAbstractButton *QMessageBox::escapeButton() const
|
|||||||
/*!
|
/*!
|
||||||
\since 4.2
|
\since 4.2
|
||||||
|
|
||||||
Sets the button that gets activated when the \key Escape key is
|
Sets the button that gets activated when the \uicontrol Escape key is
|
||||||
pressed to \a button.
|
pressed to \a button.
|
||||||
|
|
||||||
\sa addButton(), clickedButton()
|
\sa addButton(), clickedButton()
|
||||||
@ -960,7 +960,7 @@ void QMessageBox::setEscapeButton(QAbstractButton *button)
|
|||||||
/*!
|
/*!
|
||||||
\since 4.3
|
\since 4.3
|
||||||
|
|
||||||
Sets the buttons that gets activated when the \key Escape key is
|
Sets the buttons that gets activated when the \uicontrol Escape key is
|
||||||
pressed to \a button.
|
pressed to \a button.
|
||||||
|
|
||||||
\sa addButton(), clickedButton()
|
\sa addButton(), clickedButton()
|
||||||
@ -1019,7 +1019,7 @@ void QMessageBoxPrivate::detectEscapeButton()
|
|||||||
\since 4.2
|
\since 4.2
|
||||||
|
|
||||||
Returns the button that was clicked by the user,
|
Returns the button that was clicked by the user,
|
||||||
or 0 if the user hit the \key Esc key and
|
or 0 if the user hit the \uicontrol Esc key and
|
||||||
no \l{setEscapeButton()}{escape button} was set.
|
no \l{setEscapeButton()}{escape button} was set.
|
||||||
|
|
||||||
If exec() hasn't been called yet, returns 0.
|
If exec() hasn't been called yet, returns 0.
|
||||||
@ -1518,13 +1518,13 @@ static QMessageBox::StandardButton showNewMessageBox(QWidget *parent,
|
|||||||
\a text in front of the specified \a parent widget.
|
\a text in front of the specified \a parent widget.
|
||||||
|
|
||||||
The standard \a buttons are added to the message box.
|
The standard \a buttons are added to the message box.
|
||||||
\a defaultButton specifies the button used when \key Enter is pressed.
|
\a defaultButton specifies the button used when \uicontrol Enter is pressed.
|
||||||
\a defaultButton must refer to a button that was given in \a buttons.
|
\a defaultButton must refer to a button that was given in \a buttons.
|
||||||
If \a defaultButton is QMessageBox::NoButton, QMessageBox
|
If \a defaultButton is QMessageBox::NoButton, QMessageBox
|
||||||
chooses a suitable default automatically.
|
chooses a suitable default automatically.
|
||||||
|
|
||||||
Returns the identity of the standard button that was clicked. If
|
Returns the identity of the standard button that was clicked. If
|
||||||
\key Esc was pressed instead, the \l{Default and Escape Keys}
|
\uicontrol Esc was pressed instead, the \l{Default and Escape Keys}
|
||||||
{escape button} is returned.
|
{escape button} is returned.
|
||||||
|
|
||||||
The message box is an \l{Qt::ApplicationModal}{application modal}
|
The message box is an \l{Qt::ApplicationModal}{application modal}
|
||||||
@ -1552,13 +1552,13 @@ QMessageBox::StandardButton QMessageBox::information(QWidget *parent, const QStr
|
|||||||
text in front of the specified \a parent widget.
|
text in front of the specified \a parent widget.
|
||||||
|
|
||||||
The standard \a buttons are added to the message box. \a
|
The standard \a buttons are added to the message box. \a
|
||||||
defaultButton specifies the button used when \key Enter is
|
defaultButton specifies the button used when \uicontrol Enter is
|
||||||
pressed. \a defaultButton must refer to a button that was given in \a buttons.
|
pressed. \a defaultButton must refer to a button that was given in \a buttons.
|
||||||
If \a defaultButton is QMessageBox::NoButton, QMessageBox
|
If \a defaultButton is QMessageBox::NoButton, QMessageBox
|
||||||
chooses a suitable default automatically.
|
chooses a suitable default automatically.
|
||||||
|
|
||||||
Returns the identity of the standard button that was clicked. If
|
Returns the identity of the standard button that was clicked. If
|
||||||
\key Esc was pressed instead, the \l{Default and Escape Keys}
|
\uicontrol Esc was pressed instead, the \l{Default and Escape Keys}
|
||||||
{escape button} is returned.
|
{escape button} is returned.
|
||||||
|
|
||||||
The message box is an \l{Qt::ApplicationModal} {application modal}
|
The message box is an \l{Qt::ApplicationModal} {application modal}
|
||||||
@ -1584,13 +1584,13 @@ QMessageBox::StandardButton QMessageBox::question(QWidget *parent, const QString
|
|||||||
text in front of the specified \a parent widget.
|
text in front of the specified \a parent widget.
|
||||||
|
|
||||||
The standard \a buttons are added to the message box. \a
|
The standard \a buttons are added to the message box. \a
|
||||||
defaultButton specifies the button used when \key Enter is
|
defaultButton specifies the button used when \uicontrol Enter is
|
||||||
pressed. \a defaultButton must refer to a button that was given in \a buttons.
|
pressed. \a defaultButton must refer to a button that was given in \a buttons.
|
||||||
If \a defaultButton is QMessageBox::NoButton, QMessageBox
|
If \a defaultButton is QMessageBox::NoButton, QMessageBox
|
||||||
chooses a suitable default automatically.
|
chooses a suitable default automatically.
|
||||||
|
|
||||||
Returns the identity of the standard button that was clicked. If
|
Returns the identity of the standard button that was clicked. If
|
||||||
\key Esc was pressed instead, the \l{Default and Escape Keys}
|
\uicontrol Esc was pressed instead, the \l{Default and Escape Keys}
|
||||||
{escape button} is returned.
|
{escape button} is returned.
|
||||||
|
|
||||||
The message box is an \l{Qt::ApplicationModal} {application modal}
|
The message box is an \l{Qt::ApplicationModal} {application modal}
|
||||||
@ -1616,13 +1616,13 @@ QMessageBox::StandardButton QMessageBox::warning(QWidget *parent, const QString
|
|||||||
text in front of the specified \a parent widget.
|
text in front of the specified \a parent widget.
|
||||||
|
|
||||||
The standard \a buttons are added to the message box. \a
|
The standard \a buttons are added to the message box. \a
|
||||||
defaultButton specifies the button used when \key Enter is
|
defaultButton specifies the button used when \uicontrol Enter is
|
||||||
pressed. \a defaultButton must refer to a button that was given in \a buttons.
|
pressed. \a defaultButton must refer to a button that was given in \a buttons.
|
||||||
If \a defaultButton is QMessageBox::NoButton, QMessageBox
|
If \a defaultButton is QMessageBox::NoButton, QMessageBox
|
||||||
chooses a suitable default automatically.
|
chooses a suitable default automatically.
|
||||||
|
|
||||||
Returns the identity of the standard button that was clicked. If
|
Returns the identity of the standard button that was clicked. If
|
||||||
\key Esc was pressed instead, the \l{Default and Escape Keys}
|
\uicontrol Esc was pressed instead, the \l{Default and Escape Keys}
|
||||||
{escape button} is returned.
|
{escape button} is returned.
|
||||||
|
|
||||||
The message box is an \l{Qt::ApplicationModal} {application modal}
|
The message box is an \l{Qt::ApplicationModal} {application modal}
|
||||||
@ -1958,7 +1958,7 @@ void QMessageBoxPrivate::retranslateStrings()
|
|||||||
pressed).
|
pressed).
|
||||||
|
|
||||||
One of the buttons can be OR-ed with the QMessageBox::Escape flag
|
One of the buttons can be OR-ed with the QMessageBox::Escape flag
|
||||||
to make it the cancel or close button (clicked when \key Esc is
|
to make it the cancel or close button (clicked when \uicontrol Esc is
|
||||||
pressed).
|
pressed).
|
||||||
|
|
||||||
\snippet dialogs/dialogs.cpp 2
|
\snippet dialogs/dialogs.cpp 2
|
||||||
@ -2045,8 +2045,8 @@ int QMessageBox::information(QWidget *parent, const QString &title, const QStrin
|
|||||||
default button; pressing Return or Enter is the same as clicking
|
default button; pressing Return or Enter is the same as clicking
|
||||||
the default button. It defaults to 0 (the first button). \a
|
the default button. It defaults to 0 (the first button). \a
|
||||||
escapeButtonNumber is the index of the escape button; pressing
|
escapeButtonNumber is the index of the escape button; pressing
|
||||||
\key Esc is the same as clicking this button. It defaults to -1;
|
\uicontrol Esc is the same as clicking this button. It defaults to -1;
|
||||||
supply 0, 1 or 2 to make pressing \key Esc equivalent to clicking
|
supply 0, 1 or 2 to make pressing \uicontrol Esc equivalent to clicking
|
||||||
the relevant button.
|
the relevant button.
|
||||||
|
|
||||||
The message box is an \l{Qt::ApplicationModal} {application modal}
|
The message box is an \l{Qt::ApplicationModal} {application modal}
|
||||||
|
@ -704,11 +704,11 @@
|
|||||||
par les classes qui instancient \c FindDialog, ce qui leur permet d'obtenir
|
par les classes qui instancient \c FindDialog, ce qui leur permet d'obtenir
|
||||||
le texte entré par l'utilisateur. Un slot public, \c findClicked(), est
|
le texte entré par l'utilisateur. Un slot public, \c findClicked(), est
|
||||||
défini pour prendre en charge le texte lorsque l'utilisateur clique sur
|
défini pour prendre en charge le texte lorsque l'utilisateur clique sur
|
||||||
le bouton \gui Find.
|
le bouton \uicontrol Find.
|
||||||
|
|
||||||
Finalement, nous définissons les variables privées \c findButton,
|
Finalement, nous définissons les variables privées \c findButton,
|
||||||
\c lineEdit et \c findText, qui correspondent respectivement au bouton
|
\c lineEdit et \c findText, qui correspondent respectivement au bouton
|
||||||
\gui Find, au champ de texte dans lequel l'utilisateur tape le texte
|
\uicontrol Find, au champ de texte dans lequel l'utilisateur tape le texte
|
||||||
à rechercher, et à une variable interne stockant le texte pour une
|
à rechercher, et à une variable interne stockant le texte pour une
|
||||||
utilisation ultérieure.
|
utilisation ultérieure.
|
||||||
|
|
||||||
@ -733,7 +733,7 @@
|
|||||||
\image addressbook-tutorial-part5-signals-and-slots.png
|
\image addressbook-tutorial-part5-signals-and-slots.png
|
||||||
|
|
||||||
Dans \c findClicked(), nous validons le champ de texte pour nous
|
Dans \c findClicked(), nous validons le champ de texte pour nous
|
||||||
assurer que l'utilisateur n'a pas cliqué sur le bouton \gui Find sans
|
assurer que l'utilisateur n'a pas cliqué sur le bouton \uicontrol Find sans
|
||||||
avoir entré un nom de contact. Ensuite, nous stockons le texte du champ
|
avoir entré un nom de contact. Ensuite, nous stockons le texte du champ
|
||||||
d'entrée \c lineEdit dans \c findText. Et finalement nous vidons le
|
d'entrée \c lineEdit dans \c findText. Et finalement nous vidons le
|
||||||
contenu de \c lineEdit et cachons la boîte de dialogue.
|
contenu de \c lineEdit et cachons la boîte de dialogue.
|
||||||
@ -759,7 +759,7 @@
|
|||||||
|
|
||||||
Jusqu'ici, toutes les fonctionnalités du carnet d'adresses ont un
|
Jusqu'ici, toutes les fonctionnalités du carnet d'adresses ont un
|
||||||
QPushButton et un slot correspondant. De la même façon, pour la
|
QPushButton et un slot correspondant. De la même façon, pour la
|
||||||
fonctionnalité \gui Find, nous avons \c findButton et \c findContact().
|
fonctionnalité \uicontrol Find, nous avons \c findButton et \c findContact().
|
||||||
|
|
||||||
Le \c findButton est déclaré comme une variable privée et la
|
Le \c findButton est déclaré comme une variable privée et la
|
||||||
méthode \c findContact() est déclarée comme un slot public.
|
méthode \c findContact() est déclarée comme un slot public.
|
||||||
@ -856,7 +856,7 @@
|
|||||||
Idéalement, l'interface serait plus conviviale avec des boutons
|
Idéalement, l'interface serait plus conviviale avec des boutons
|
||||||
affichant "Load contacts from a file" et "Save contacts to a file". Mais
|
affichant "Load contacts from a file" et "Save contacts to a file". Mais
|
||||||
compte tenu de la dimension des autres boutons, on initialise les labels
|
compte tenu de la dimension des autres boutons, on initialise les labels
|
||||||
des boutons à \gui{Load...} et \gui{Save...}. Heureusement, Qt offre une
|
des boutons à \uicontrol{Load...} et \uicontrol{Save...}. Heureusement, Qt offre une
|
||||||
façon simple d'ajouter des info-bulles avec
|
façon simple d'ajouter des info-bulles avec
|
||||||
\l{QWidget::setToolTip()}{setToolTip()}, et nous l'exploitons de la façon
|
\l{QWidget::setToolTip()}{setToolTip()}, et nous l'exploitons de la façon
|
||||||
suivante pour nos boutons:
|
suivante pour nos boutons:
|
||||||
|
@ -276,8 +276,8 @@
|
|||||||
|
|
||||||
We also declare two private QString objects, \c oldName and \c oldAddress.
|
We also declare two private QString objects, \c oldName and \c oldAddress.
|
||||||
These objects are needed to hold the name and address of the contact that
|
These objects are needed to hold the name and address of the contact that
|
||||||
was last displayed, before the user clicked \gui Add. So, when the user clicks
|
was last displayed, before the user clicked \uicontrol Add. So, when the user clicks
|
||||||
\gui Cancel, we can revert to displaying the details of the last contact.
|
\uicontrol Cancel, we can revert to displaying the details of the last contact.
|
||||||
|
|
||||||
\section1 Implementing the AddressBook Class
|
\section1 Implementing the AddressBook Class
|
||||||
|
|
||||||
@ -298,7 +298,7 @@
|
|||||||
The \c addButton is displayed by invoking the \l{QPushButton::show()}
|
The \c addButton is displayed by invoking the \l{QPushButton::show()}
|
||||||
{show()} function, while the \c submitButton and \c cancelButton are
|
{show()} function, while the \c submitButton and \c cancelButton are
|
||||||
hidden by invoking \l{QPushButton::hide()}{hide()}. These two push
|
hidden by invoking \l{QPushButton::hide()}{hide()}. These two push
|
||||||
buttons will only be displayed when the user clicks \gui Add and this is
|
buttons will only be displayed when the user clicks \uicontrol Add and this is
|
||||||
handled by the \c addContact() function discussed below.
|
handled by the \c addContact() function discussed below.
|
||||||
|
|
||||||
\snippet tutorials/addressbook/part2/addressbook.cpp connecting signals and slots
|
\snippet tutorials/addressbook/part2/addressbook.cpp connecting signals and slots
|
||||||
@ -342,7 +342,7 @@
|
|||||||
\list 1
|
\list 1
|
||||||
\li We extract the contact's details from \c nameLine and \c addressText
|
\li We extract the contact's details from \c nameLine and \c addressText
|
||||||
and store them in QString objects. We also validate to make sure that the
|
and store them in QString objects. We also validate to make sure that the
|
||||||
user did not click \gui Submit with empty input fields; otherwise, a
|
user did not click \uicontrol Submit with empty input fields; otherwise, a
|
||||||
QMessageBox is displayed to remind the user for a name and address.
|
QMessageBox is displayed to remind the user for a name and address.
|
||||||
|
|
||||||
\snippet tutorials/addressbook/part2/addressbook.cpp submitContact part1
|
\snippet tutorials/addressbook/part2/addressbook.cpp submitContact part1
|
||||||
@ -377,7 +377,7 @@
|
|||||||
\snippet tutorials/addressbook/part2/addressbook.cpp cancel
|
\snippet tutorials/addressbook/part2/addressbook.cpp cancel
|
||||||
|
|
||||||
The general idea behind adding a contact is to give the user the
|
The general idea behind adding a contact is to give the user the
|
||||||
flexibility to click \gui Submit or \gui Cancel at any time. The flowchart below
|
flexibility to click \uicontrol Submit or \uicontrol Cancel at any time. The flowchart below
|
||||||
further explains this concept:
|
further explains this concept:
|
||||||
|
|
||||||
\image addressbook-tutorial-part2-add-flowchart.png
|
\image addressbook-tutorial-part2-add-flowchart.png
|
||||||
@ -673,11 +673,11 @@
|
|||||||
We define a public function, \c getFindText(), to be used by classes that
|
We define a public function, \c getFindText(), to be used by classes that
|
||||||
instantiate \c FindDialog. This function allows these classes to obtain the
|
instantiate \c FindDialog. This function allows these classes to obtain the
|
||||||
search string entered by the user. A public slot, \c findClicked(), is also
|
search string entered by the user. A public slot, \c findClicked(), is also
|
||||||
defined to handle the search string when the user clicks the \gui Find
|
defined to handle the search string when the user clicks the \uicontrol Find
|
||||||
button.
|
button.
|
||||||
|
|
||||||
Lastly, we define the private variables, \c findButton, \c lineEdit
|
Lastly, we define the private variables, \c findButton, \c lineEdit
|
||||||
and \c findText, corresponding to the \gui Find button, the line edit
|
and \c findText, corresponding to the \uicontrol Find button, the line edit
|
||||||
into which the user types the search string, and an internal string
|
into which the user types the search string, and an internal string
|
||||||
used to store the search string for later use.
|
used to store the search string for later use.
|
||||||
|
|
||||||
@ -702,7 +702,7 @@
|
|||||||
\image addressbook-tutorial-part5-signals-and-slots.png
|
\image addressbook-tutorial-part5-signals-and-slots.png
|
||||||
|
|
||||||
In \c findClicked(), we validate \c lineEdit to ensure that the user
|
In \c findClicked(), we validate \c lineEdit to ensure that the user
|
||||||
did not click the \gui Find button without entering a contact's name. Then, we set
|
did not click the \uicontrol Find button without entering a contact's name. Then, we set
|
||||||
\c findText to the search string, extracted from \c lineEdit. After that,
|
\c findText to the search string, extracted from \c lineEdit. After that,
|
||||||
we clear the contents of \c lineEdit and hide the dialog.
|
we clear the contents of \c lineEdit and hide the dialog.
|
||||||
|
|
||||||
@ -726,7 +726,7 @@
|
|||||||
\snippet tutorials/addressbook/part5/addressbook.h include finddialog's header
|
\snippet tutorials/addressbook/part5/addressbook.h include finddialog's header
|
||||||
|
|
||||||
So far, all our address book features have a QPushButton and a
|
So far, all our address book features have a QPushButton and a
|
||||||
corresponding slot. Similarly, for the \gui Find feature we have
|
corresponding slot. Similarly, for the \uicontrol Find feature we have
|
||||||
\c findButton and \c findContact().
|
\c findButton and \c findContact().
|
||||||
|
|
||||||
The \c findButton is declared as a private variable and the
|
The \c findButton is declared as a private variable and the
|
||||||
@ -821,8 +821,8 @@
|
|||||||
In our constructor, we instantiate \c loadButton and \c saveButton.
|
In our constructor, we instantiate \c loadButton and \c saveButton.
|
||||||
Ideally, it would be more user-friendly to set the push buttons' labels
|
Ideally, it would be more user-friendly to set the push buttons' labels
|
||||||
to "Load contacts from a file" and "Save contacts to a file". However, due
|
to "Load contacts from a file" and "Save contacts to a file". However, due
|
||||||
to the size of our other push buttons, we set the labels to \gui{Load...}
|
to the size of our other push buttons, we set the labels to \uicontrol{Load...}
|
||||||
and \gui{Save...}. Fortunately, Qt provides a simple way to set tooltips with
|
and \uicontrol{Save...}. Fortunately, Qt provides a simple way to set tooltips with
|
||||||
\l{QWidget::setToolTip()}{setToolTip()} and we use it in the following way
|
\l{QWidget::setToolTip()}{setToolTip()} and we use it in the following way
|
||||||
for our push buttons:
|
for our push buttons:
|
||||||
|
|
||||||
|
@ -851,7 +851,7 @@
|
|||||||
|
|
||||||
The behavior of the spin box could be adjusted to make it more user
|
The behavior of the spin box could be adjusted to make it more user
|
||||||
friendly. In the default event filter supplied by QItemDelegate, if
|
friendly. In the default event filter supplied by QItemDelegate, if
|
||||||
the user hits \key Return to confirm their choice in the spin box,
|
the user hits \uicontrol Return to confirm their choice in the spin box,
|
||||||
the delegate commits the value to the model and closes the spin box.
|
the delegate commits the value to the model and closes the spin box.
|
||||||
We can change this behavior by installing our own event filter on the
|
We can change this behavior by installing our own event filter on the
|
||||||
spin box, and provide editing hints that suit our needs; for example,
|
spin box, and provide editing hints that suit our needs; for example,
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
|
|
||||||
\list 1
|
\list 1
|
||||||
|
|
||||||
\li The user presses \key Tab (or \key Shift+Tab).
|
\li The user presses \uicontrol Tab (or \uicontrol Shift+Tab).
|
||||||
\li The user clicks a widget.
|
\li The user clicks a widget.
|
||||||
\li The user presses a keyboard shortcut.
|
\li The user presses a keyboard shortcut.
|
||||||
\li The user uses the mouse wheel.
|
\li The user uses the mouse wheel.
|
||||||
@ -65,36 +65,36 @@
|
|||||||
|
|
||||||
\section2 Tab or Shift+Tab
|
\section2 Tab or Shift+Tab
|
||||||
|
|
||||||
Pressing \key Tab is by far the most common way to move focus
|
Pressing \uicontrol Tab is by far the most common way to move focus
|
||||||
using the keyboard. (Sometimes in data-entry applications Enter
|
using the keyboard. (Sometimes in data-entry applications Enter
|
||||||
does the same as \key{Tab}; this can easily be achieved in Qt by
|
does the same as \uicontrol{Tab}; this can easily be achieved in Qt by
|
||||||
implementing an \l{The Event System}{event filter}.)
|
implementing an \l{The Event System}{event filter}.)
|
||||||
|
|
||||||
Pressing \key Tab, in all window systems in common use today,
|
Pressing \uicontrol Tab, in all window systems in common use today,
|
||||||
moves the keyboard focus to the next widget in a circular
|
moves the keyboard focus to the next widget in a circular
|
||||||
per-window list. \key Tab moves focus along the circular list in
|
per-window list. \uicontrol Tab moves focus along the circular list in
|
||||||
one direction, \key Shift+Tab in the other. The order in which
|
one direction, \uicontrol Shift+Tab in the other. The order in which
|
||||||
\key Tab presses move from widget to widget is called the tab order.
|
\uicontrol Tab presses move from widget to widget is called the tab order.
|
||||||
|
|
||||||
You can customize the tab order using QWidget::setTabOrder(). (If
|
You can customize the tab order using QWidget::setTabOrder(). (If
|
||||||
you don't, \key Tab generally moves focus in the order of widget
|
you don't, \uicontrol Tab generally moves focus in the order of widget
|
||||||
construction.) \l{Qt Designer} provides a means of visually
|
construction.) \l{Qt Designer} provides a means of visually
|
||||||
changing the tab order.
|
changing the tab order.
|
||||||
|
|
||||||
Since pressing \key Tab is so common, most widgets that can have focus
|
Since pressing \uicontrol Tab is so common, most widgets that can have focus
|
||||||
should support tab focus. The major exception is widgets that are
|
should support tab focus. The major exception is widgets that are
|
||||||
rarely used, and where there is some keyboard accelerator or error
|
rarely used, and where there is some keyboard accelerator or error
|
||||||
handler that moves the focus.
|
handler that moves the focus.
|
||||||
|
|
||||||
For example, in a data entry dialog, there might be a field that
|
For example, in a data entry dialog, there might be a field that
|
||||||
is only necessary in one per cent of all cases. In such a dialog,
|
is only necessary in one per cent of all cases. In such a dialog,
|
||||||
\key Tab could skip this field, and the dialog could use one of
|
\uicontrol Tab could skip this field, and the dialog could use one of
|
||||||
these mechanisms:
|
these mechanisms:
|
||||||
|
|
||||||
\list 1
|
\list 1
|
||||||
|
|
||||||
\li If the program can determine whether the field is needed, it can
|
\li If the program can determine whether the field is needed, it can
|
||||||
move focus there when the user finishes entry and presses \gui OK, or when
|
move focus there when the user finishes entry and presses \uicontrol OK, or when
|
||||||
the user presses Enter after finishing the other fields. Alternately,
|
the user presses Enter after finishing the other fields. Alternately,
|
||||||
include the field in the tab order but disable it. Enable it if it
|
include the field in the tab order but disable it. Enable it if it
|
||||||
becomes appropriate in view of what the user has set in the other
|
becomes appropriate in view of what the user has set in the other
|
||||||
@ -105,22 +105,22 @@
|
|||||||
|
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
Another exception to \key Tab support is text-entry widgets that
|
Another exception to \uicontrol Tab support is text-entry widgets that
|
||||||
must support the insertion of tabs; almost all text editors fall
|
must support the insertion of tabs; almost all text editors fall
|
||||||
into this class. Qt treats \key Ctrl+Tab as \key Tab and \key
|
into this class. Qt treats \uicontrol Ctrl+Tab as \uicontrol Tab and \uicontrol
|
||||||
Ctrl+Shift+Tab as \key Shift+Tab, and such widgets can
|
Ctrl+Shift+Tab as \uicontrol Shift+Tab, and such widgets can
|
||||||
reimplement QWidget::event() and handle Tab before calling
|
reimplement QWidget::event() and handle Tab before calling
|
||||||
QWidget::event() to get normal processing of all other keys.
|
QWidget::event() to get normal processing of all other keys.
|
||||||
However, since some systems use \key Ctrl+Tab for other purposes,
|
However, since some systems use \uicontrol Ctrl+Tab for other purposes,
|
||||||
and many users aren't aware of \key Ctrl+Tab anyway, this isn't a
|
and many users aren't aware of \uicontrol Ctrl+Tab anyway, this isn't a
|
||||||
complete solution.
|
complete solution.
|
||||||
|
|
||||||
\section2 The User Clicks a Widget
|
\section2 The User Clicks a Widget
|
||||||
|
|
||||||
This is perhaps even more common than pressing \key Tab on
|
This is perhaps even more common than pressing \uicontrol Tab on
|
||||||
computers with a mouse or other pointing device.
|
computers with a mouse or other pointing device.
|
||||||
|
|
||||||
Clicking to move the focus is slightly more powerful than \key
|
Clicking to move the focus is slightly more powerful than \uicontrol
|
||||||
Tab. While it moves the focus \e to a widget, for editor widgets
|
Tab. While it moves the focus \e to a widget, for editor widgets
|
||||||
it also moves the text cursor (the widget's internal focus) to
|
it also moves the text cursor (the widget's internal focus) to
|
||||||
the spot where the mouse is clicked.
|
the spot where the mouse is clicked.
|
||||||
@ -152,10 +152,10 @@
|
|||||||
|
|
||||||
We advise supporting shortcut focus for all widgets that the user
|
We advise supporting shortcut focus for all widgets that the user
|
||||||
may want to jump to. For example, a tab dialog can have keyboard
|
may want to jump to. For example, a tab dialog can have keyboard
|
||||||
shortcuts for each of its pages, so the user can press e.g. \key
|
shortcuts for each of its pages, so the user can press e.g. \uicontrol
|
||||||
Alt+P to step to the \underline{P}rinting page. It is easy to
|
Alt+P to step to the \underline{P}rinting page. It is easy to
|
||||||
overdo this: there are only a few keys, and it's also important
|
overdo this: there are only a few keys, and it's also important
|
||||||
to provide keyboard shortcuts for commands. \key Alt+P is also
|
to provide keyboard shortcuts for commands. \uicontrol Alt+P is also
|
||||||
used for Paste, Play, Print, and Print Here in the \l{Standard
|
used for Paste, Play, Print, and Print Here in the \l{Standard
|
||||||
Accelerator Keys} list, for example.
|
Accelerator Keys} list, for example.
|
||||||
|
|
||||||
|
@ -550,18 +550,18 @@
|
|||||||
|
|
||||||
\l{Qt Designer}{Qt Designer} is an excellent tool
|
\l{Qt Designer}{Qt Designer} is an excellent tool
|
||||||
to preview style sheets. You can right-click on any widget in Designer
|
to preview style sheets. You can right-click on any widget in Designer
|
||||||
and select \gui{Change styleSheet...} to set the style sheet.
|
and select \uicontrol{Change styleSheet...} to set the style sheet.
|
||||||
|
|
||||||
\image designer-stylesheet-options.png
|
\image designer-stylesheet-options.png
|
||||||
|
|
||||||
In Qt 4.2 and later, \l{Qt Designer}{Qt Designer} also includes a
|
In Qt 4.2 and later, \l{Qt Designer}{Qt Designer} also includes a
|
||||||
style sheet syntax highlighter and validator. The validator indicates
|
style sheet syntax highlighter and validator. The validator indicates
|
||||||
if the syntax is valid or invalid, at the bottom left of the \gui{Edit
|
if the syntax is valid or invalid, at the bottom left of the \uicontrol{Edit
|
||||||
Style Sheet} dialog.
|
Style Sheet} dialog.
|
||||||
|
|
||||||
\image designer-validator-highlighter.png
|
\image designer-validator-highlighter.png
|
||||||
|
|
||||||
When you click \gui{OK} or \gui{Apply}, \QD will automatically display
|
When you click \uicontrol{OK} or \uicontrol{Apply}, \QD will automatically display
|
||||||
the widget with its new stylesheet.
|
the widget with its new stylesheet.
|
||||||
|
|
||||||
\image designer-stylesheet-usage.png
|
\image designer-stylesheet-usage.png
|
||||||
|
@ -106,13 +106,13 @@
|
|||||||
\li From a command prompt, enter the directory containing the
|
\li From a command prompt, enter the directory containing the
|
||||||
example you have modified.
|
example you have modified.
|
||||||
|
|
||||||
\li Type \c qmake and press \key{Return}. If this doesn't work,
|
\li Type \c qmake and press \uicontrol{Return}. If this doesn't work,
|
||||||
make sure that the executable is on your path, or enter its
|
make sure that the executable is on your path, or enter its
|
||||||
full location.
|
full location.
|
||||||
|
|
||||||
\li On Linux/Unix and Mac OS X, type \c make and press
|
\li On Linux/Unix and Mac OS X, type \c make and press
|
||||||
\key{Return}; on Windows with Visual Studio, type \c nmake and
|
\uicontrol{Return}; on Windows with Visual Studio, type \c nmake and
|
||||||
press \key{Return}.
|
press \uicontrol{Return}.
|
||||||
|
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
|
@ -1259,7 +1259,7 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
|
|||||||
activated when the user clicks or double clicks on it, depending on the
|
activated when the user clicks or double clicks on it, depending on the
|
||||||
system configuration. It is also activated when the user presses the
|
system configuration. It is also activated when the user presses the
|
||||||
activation key (on Windows and X11 this is the \uicontrol Return key, on Mac OS
|
activation key (on Windows and X11 this is the \uicontrol Return key, on Mac OS
|
||||||
X it is \key{Ctrl+0}).
|
X it is \uicontrol{Ctrl+0}).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -2402,7 +2402,7 @@ void QTreeWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft,
|
|||||||
This signal is emitted when the user activates an item by single-
|
This signal is emitted when the user activates an item by single-
|
||||||
or double-clicking (depending on the platform, i.e. on the
|
or double-clicking (depending on the platform, i.e. on the
|
||||||
QStyle::SH_ItemView_ActivateItemOnSingleClick style hint) or
|
QStyle::SH_ItemView_ActivateItemOnSingleClick style hint) or
|
||||||
pressing a special key (e.g., \key Enter).
|
pressing a special key (e.g., \uicontrol Enter).
|
||||||
|
|
||||||
The specified \a item is the item that was clicked, or 0 if no
|
The specified \a item is the item that was clicked, or 0 if no
|
||||||
item was clicked. The \a column is the item's column that was
|
item was clicked. The \a column is the item's column that was
|
||||||
|
@ -629,7 +629,7 @@ void QWidget::setAutoFillBackground(bool enabled)
|
|||||||
\list
|
\list
|
||||||
\li keyPressEvent() is called whenever a key is pressed, and again when
|
\li keyPressEvent() is called whenever a key is pressed, and again when
|
||||||
a key has been held down long enough for it to auto-repeat. The
|
a key has been held down long enough for it to auto-repeat. The
|
||||||
\key Tab and \key Shift+Tab keys are only passed to the widget if
|
\uicontrol Tab and \uicontrol Shift+Tab keys are only passed to the widget if
|
||||||
they are not used by the focus-change mechanisms. To force those
|
they are not used by the focus-change mechanisms. To force those
|
||||||
keys to be processed by your widget, you must reimplement
|
keys to be processed by your widget, you must reimplement
|
||||||
QWidget::event().
|
QWidget::event().
|
||||||
@ -652,7 +652,7 @@ void QWidget::setAutoFillBackground(bool enabled)
|
|||||||
\li keyReleaseEvent() is called whenever a key is released and while it
|
\li keyReleaseEvent() is called whenever a key is released and while it
|
||||||
is held down (if the key is auto-repeating). In that case, the
|
is held down (if the key is auto-repeating). In that case, the
|
||||||
widget will receive a pair of key release and key press event for
|
widget will receive a pair of key release and key press event for
|
||||||
every repeat. The \key Tab and \key Shift+Tab keys are only passed
|
every repeat. The \uicontrol Tab and \uicontrol Shift+Tab keys are only passed
|
||||||
to the widget if they are not used by the focus-change mechanisms.
|
to the widget if they are not used by the focus-change mechanisms.
|
||||||
To force those keys to be processed by your widget, you must
|
To force those keys to be processed by your widget, you must
|
||||||
reimplement QWidget::event().
|
reimplement QWidget::event().
|
||||||
@ -674,7 +674,7 @@ void QWidget::setAutoFillBackground(bool enabled)
|
|||||||
for QEvent::Type. To handle these events, you need to reimplement event()
|
for QEvent::Type. To handle these events, you need to reimplement event()
|
||||||
directly.
|
directly.
|
||||||
|
|
||||||
The default implementation of event() handles \key Tab and \key Shift+Tab
|
The default implementation of event() handles \uicontrol Tab and \uicontrol Shift+Tab
|
||||||
(to move the keyboard focus), and passes on most of the other events to
|
(to move the keyboard focus), and passes on most of the other events to
|
||||||
one of the more specialized handlers above.
|
one of the more specialized handlers above.
|
||||||
|
|
||||||
@ -6079,7 +6079,7 @@ void QWidget::clearFocus()
|
|||||||
\fn bool QWidget::focusNextChild()
|
\fn bool QWidget::focusNextChild()
|
||||||
|
|
||||||
Finds a new widget to give the keyboard focus to, as appropriate
|
Finds a new widget to give the keyboard focus to, as appropriate
|
||||||
for \key Tab, and returns true if it can find a new widget, or
|
for \uicontrol Tab, and returns true if it can find a new widget, or
|
||||||
false if it can't.
|
false if it can't.
|
||||||
|
|
||||||
\sa focusPreviousChild()
|
\sa focusPreviousChild()
|
||||||
@ -6089,7 +6089,7 @@ void QWidget::clearFocus()
|
|||||||
\fn bool QWidget::focusPreviousChild()
|
\fn bool QWidget::focusPreviousChild()
|
||||||
|
|
||||||
Finds a new widget to give the keyboard focus to, as appropriate
|
Finds a new widget to give the keyboard focus to, as appropriate
|
||||||
for \key Shift+Tab, and returns true if it can find a new widget,
|
for \uicontrol Shift+Tab, and returns true if it can find a new widget,
|
||||||
or false if it can't.
|
or false if it can't.
|
||||||
|
|
||||||
\sa focusNextChild()
|
\sa focusNextChild()
|
||||||
|
@ -88,8 +88,8 @@ Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets;
|
|||||||
|
|
||||||
\snippet code/src_gui_widgets_qabstractbutton.cpp 0
|
\snippet code/src_gui_widgets_qabstractbutton.cpp 0
|
||||||
|
|
||||||
The \key Alt+C shortcut is assigned to the button, i.e., when the
|
The \uicontrol Alt+C shortcut is assigned to the button, i.e., when the
|
||||||
user presses \key Alt+C the button will call animateClick(). See
|
user presses \uicontrol Alt+C the button will call animateClick(). See
|
||||||
the \l {QShortcut#mnemonic}{QShortcut} documentation for details
|
the \l {QShortcut#mnemonic}{QShortcut} documentation for details
|
||||||
(to display an actual ampersand, use '&&').
|
(to display an actual ampersand, use '&&').
|
||||||
|
|
||||||
|
@ -215,11 +215,11 @@ int QDialPrivate::valueFromPoint(const QPoint &p) const
|
|||||||
subtractPage() available as slots.
|
subtractPage() available as slots.
|
||||||
|
|
||||||
The dial's keyboard interface is fairly simple: The
|
The dial's keyboard interface is fairly simple: The
|
||||||
\key{left}/\key{up} and \key{right}/\key{down} arrow keys adjust
|
\uicontrol{left}/\uicontrol{up} and \uicontrol{right}/\uicontrol{down} arrow keys adjust
|
||||||
the dial's \l {QAbstractSlider::value} {value} by the defined
|
the dial's \l {QAbstractSlider::value} {value} by the defined
|
||||||
\l {QAbstractSlider::singleStep} {singleStep}, \key{Page Up} and
|
\l {QAbstractSlider::singleStep} {singleStep}, \uicontrol{Page Up} and
|
||||||
\key{Page Down} by the defined \l {QAbstractSlider::pageStep}
|
\uicontrol{Page Down} by the defined \l {QAbstractSlider::pageStep}
|
||||||
{pageStep}, and the \key Home and \key End keys set the value to
|
{pageStep}, and the \uicontrol Home and \uicontrol End keys set the value to
|
||||||
the defined \l {QAbstractSlider::minimum} {minimum} and
|
the defined \l {QAbstractSlider::minimum} {minimum} and
|
||||||
\l {QAbstractSlider::maximum} {maximum} values.
|
\l {QAbstractSlider::maximum} {maximum} values.
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ void QGroupBox::setTitle(const QString &title)
|
|||||||
|
|
||||||
\snippet code/src_gui_widgets_qgroupbox.cpp 0
|
\snippet code/src_gui_widgets_qgroupbox.cpp 0
|
||||||
|
|
||||||
In the example above, \key Alt+U moves the keyboard focus to the
|
In the example above, \uicontrol Alt+U moves the keyboard focus to the
|
||||||
group box. See the \l {QShortcut#mnemonic}{QShortcut}
|
group box. See the \l {QShortcut#mnemonic}{QShortcut}
|
||||||
documentation for details (to display an actual ampersand, use
|
documentation for details (to display an actual ampersand, use
|
||||||
'&&').
|
'&&').
|
||||||
|
@ -118,7 +118,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
The length of the slider is usually related to the value of the page step,
|
The length of the slider is usually related to the value of the page step,
|
||||||
and typically represents the proportion of the document area shown in a
|
and typically represents the proportion of the document area shown in a
|
||||||
scrolling view. The page step is the amount that the value changes by
|
scrolling view. The page step is the amount that the value changes by
|
||||||
when the user presses the \key{Page Up} and \key{Page Down} keys, and is
|
when the user presses the \uicontrol{Page Up} and \uicontrol{Page Down} keys, and is
|
||||||
set with setPageStep(). Smaller changes to the value defined by the
|
set with setPageStep(). Smaller changes to the value defined by the
|
||||||
line step are made using the cursor keys, and this quantity is set with
|
line step are made using the cursor keys, and this quantity is set with
|
||||||
\l{QAbstractSlider::}{setSingleStep()}.
|
\l{QAbstractSlider::}{setSingleStep()}.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user