Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
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}

Name

qgetfontdialog — dialog for font selection

Syntax

Panel
bgColor#FFFFAA
borderWidth1
borderStylesolid

qgetfontdialog [initialfont] [parent]

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.

Arguments

initialfont

parent

Examples

Ex.1: Font dialog

Anchor
Font dialog
Font dialog

No Format
bgColor#eeeeee
borderWidth1
# 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}

Image Added

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.