FontDialog QML Type

A font dialog. More...

Import Statement: import QtQuick.Dialogs
Since: Qt 6.2
Inherits:

Dialog

Properties

Detailed Description

The FontDialog type provides a QML API for font dialogs.

To show a font dialog, construct an instance of FontDialog, set the desired properties, and call open(). The currentFont property can be used to determine the currently selected font in the dialog. The selectedFont property is updated only after the final selection has been made by accepting the dialog.

MenuItem {
    text: "Font"
    onTriggered: fontDialog.open()
}

FontDialog {
    id: fontDialog
    currentFont.family: document.font
}

MyDocument {
    id: document
    font: fontDialog.selectedFont
}

Availability

A native platform font dialog is currently available on the following platforms:

  • macOS
  • Linux (when running with the GTK+ platform theme)

Qt Quick Dialogs uses a Qt Quick implementation as a fallback on platforms that do not have a native implementation available.

Property Documentation

currentFont : font

This property holds the currently selected font in the dialog.

Unlike the selectedFont property, the currentFont property is updated while the user is selecting fonts in the dialog, even before the final selection has been made.

See also selectedFont.


options : flags

This property holds the various options that affect the look and feel of the dialog.

By default, all options are disabled.

Options should be set before showing the dialog. Setting them while the dialog is visible is not guaranteed to have an immediate effect on the dialog (depending on the option and on the platform).

Available options:

ConstantDescription
FontDialog.ScalableFontsShow scalable fonts.
FontDialog.NonScalableFontsShow non-scalable fonts.
FontDialog.MonospacedFontsShow monospaced fonts.
FontDialog.ProportionalFontsShow proportional fonts.
FontDialog.NoButtonsDon't display Open and Cancel buttons (useful for "live dialogs").

selectedFont : font

This property holds the final accepted font.

Unlike the currentFont property, the selectedFont property is not updated while the user is selecting fonts in the dialog, but only after the final selection has been made. That is, when the user has clicked Open to accept a font. Alternatively, the accepted() signal can be handled to get the final selection.

See also currentFont and accepted().


© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.