Wiki Markup |
---|
{alias:qgetfontdialog}
h2. Name
*qgetfontdialog* — dialog for font selection
h2. Syntax
{panel:|borderStyle=solid|borderWidth=1|bgColor=#FFFFAA}
*qgetfontdialog* \[_initialfont_] \[_parent_]
{panel}
h2. Description
The *qgetfontdialog* command displays a font selection dialog. The dialog provides various methods to select a font, such as font familiy, style, size etc. The dialog returns either a font object or, if the user presses the Cancel button, an empty string "".
The font dialog is +modal+, meaning script execution is halted until the user closes the dialog.
h2. Arguments
_initialfont_
{indent}
A font object that determines the initial font displayed in the dialog. This typically contains the existing font for the widget in question, allowing the user to see what font is already in use.
{indent}
_parent_
{indent}
A parent widget. If this argument is provided, the font dialog will position itself on top of the parent widget.
{indent}
h2. Examples
h3. Ex.1: Font dialog
{anchor:Font dialog}
{noformat:|borderWidth=1|bgColor=#eeeeee}
# Set editor font
proc set_font {} {
set f [qgetfontdialog]
if { $f == "" } return
qsetfont $::editor $f
qsetfont $::button $f
}
# Toplevel window with editor
set w [qwidget]
qsetwindowtitle "Font"
qvboxlayout {
set editor [qtextedit]
set button [qpushbutton "Font" set_font]
}
qshow $w
{noformat}
!att:_img_cmd^qgetfont.png!
The previous example script displays a text editor along with a button for changing the editor font. The editors existing font is used as initial font in the dialog. The editor itself is supplied as an argument to the qgetfontdialog command to ensure that the font dialog is positioned on top of the editor. Note that the button font is set as well, thus any widget can have its font set using the qsetfontdialog command.
{pagebreak} |
Page Comparison
General
Content
Integrations