Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Unknown macro: {alias}

Name

qgetfontdialog — dialog for font selection

Syntax

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

Unknown macro: {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.

parent

Unknown macro: {indent}

A parent widget. If this argument is provided, the font dialog will position itself on top of the parent widget.

Examples

Ex.1: Font dialog

# 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

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.

Unknown macro: {pagebreak}
  • No labels