com.trolltech.qt.gui
Class QFontDialog

java.lang.Object
  extended by com.trolltech.qt.internal.QSignalEmitterInternal
      extended by com.trolltech.qt.QSignalEmitter
          extended by com.trolltech.qt.QtJambiObject
              extended by com.trolltech.qt.core.QObject
                  extended by com.trolltech.qt.gui.QWidget
                      extended by com.trolltech.qt.gui.QDialog
                          extended by com.trolltech.qt.gui.QFontDialog
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface

public class QFontDialog
extends QDialog

The QFontDialog class provides a dialog widget for selecting a font. A font dialog is created through one of the static getFont() functions.

Examples:

    QFont font;
    QFontDialog.Result fontResult  = QFontDialog.getFont(new QFont("Helvetica [Cronyx]", 10), this);
    if (fontResult.ok) {
        // the user clicked OK and font is set to the font the user selected
        font = fontResult.font;
    } else {
        // the user canceled the dialog; font is set to the initial
        // value, in this case Helvetica [Cronyx], 10
    }
The dialog can also be used to set a widget's font directly:
    myWidget.setFont(QFontDialog.getFont(myWidget.font()).font);
If the user clicks OK the font they chose will be used for myWidget, and if they click Cancel the original font is used.

See also:
QFont, QFontInfo, QFontMetrics, QColorDialog, QFileDialog, QPrintDialog, and Standard Dialogs Example.


Nested Class Summary
static class QFontDialog.FontDialogOption
          This enum specifies various options that affect the look and feel of a font dialog.
static class QFontDialog.FontDialogOptions
           
static class QFontDialog.Result
           
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QDialog
QDialog.DialogCode
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
QWidget.RenderFlag, QWidget.RenderFlags
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.PrivateSignal0, QSignalEmitter.PrivateSignal1, QSignalEmitter.PrivateSignal2, QSignalEmitter.PrivateSignal3, QSignalEmitter.PrivateSignal4, QSignalEmitter.PrivateSignal5, QSignalEmitter.PrivateSignal6, QSignalEmitter.PrivateSignal7, QSignalEmitter.PrivateSignal8, QSignalEmitter.PrivateSignal9, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9
 
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal
 
Field Summary
 QSignalEmitter.Signal1 currentFontChanged
          This signal takes 1 generic argument(s).
 QSignalEmitter.Signal1 fontSelected
          This signal takes 1 generic argument(s).
 
Fields inherited from class com.trolltech.qt.gui.QDialog
accepted, finished, rejected
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
currentSender
 
Constructor Summary
QFontDialog()
          Constructs a standard font dialog.
QFontDialog(QFont initial)
          Constructs a standard font dialog with the given parent and specified initial color.
QFontDialog(QFont initial, QWidget parent)
          Constructs a standard font dialog with the given parent and specified initial color.
QFontDialog(QWidget parent)
          Constructs a standard font dialog.
 
Method Summary
 QFont currentFont()
           
static QFontDialog.Result getFont()
          This is an overloaded method provided for convenience.
static QFontDialog.Result getFont(QFont initial)
          This is an overloaded method provided for convenience.
static QFontDialog.Result getFont(QFont initial, QWidget parent)
          This is an overloaded method provided for convenience.
static QFontDialog.Result getFont(QFont initial, QWidget parent, java.lang.String caption)
          Executes a modal font dialog and returns a font.
static QFontDialog.Result getFont(QFont initial, QWidget parent, java.lang.String title, QFontDialog.FontDialogOptions options)
          This is an overloaded method provided for convenience.
static QFontDialog.Result getFont(QWidget parent)
          This is an overloaded method provided for convenience.
 QFontDialog.FontDialogOptions options()
          This property holds the various options that affect the look and feel of the dialog.
 QFont selectedFont()
          Returns the font that the user selected by clicking the OK or equivalent button.
 void setCurrentFont(QFont font)
           
 void setOption(QFontDialog.FontDialogOption option)
          Sets the given option to be enabled if on is true; otherwise, clears the given option.
 void setOption(QFontDialog.FontDialogOption option, boolean on)
          Sets the given option to be enabled if on is true; otherwise, clears the given option.
 void setOptions(QFontDialog.FontDialogOption[] options)
          This is an overloaded method provided for convenience.
 void setOptions(QFontDialog.FontDialogOptions options)
          This property holds the various options that affect the look and feel of the dialog.
 boolean testOption(QFontDialog.FontDialogOption option)
          Returns true if the given option is enabled; otherwise, returns false.
 
Methods inherited from class com.trolltech.qt.gui.QDialog
accept, done, exec, isSizeGripEnabled, open, reject, result, setModal, setResult, setSizeGripEnabled
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, changeEvent, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, cursor, depth, destroy, destroy, destroy, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveWinId, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, graphicsProxyWidget, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isMaximized, isMinimized, isModal, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, languageChange, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nativeParentWidget, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, paintEngine, paintEvent, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFilePath, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFilePath, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
__qt_signalInitialization
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

currentFontChanged

public final QSignalEmitter.Signal1 currentFontChanged

This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.gui.QFont(named: font)>:

This signal is emitted when the current font is changed. The new font is specified in font.

The signal is emitted while a user is selecting a font. Ultimately, the chosen font may differ from the font currently selected.

See also:
currentFont, fontSelected() , and selectedFont().


fontSelected

public final QSignalEmitter.Signal1 fontSelected

This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.gui.QFont(named: font)>:

This signal is emitted when a font has been selected. The selected font is specified in font.

The signal is only emitted when a user has chosen the final font to be used. It is not emitted while the user is changing the current font in the font dialog.

See also:
selectedFont(), currentFontChanged() , and currentFont.

Constructor Detail

QFontDialog

public QFontDialog()
Constructs a standard font dialog.

Use setCurrentFont() to set the initial font attributes.

The parent parameter is passed to the QDialog constructor.

See also:
getFont().


QFontDialog

public QFontDialog(QWidget parent)
Constructs a standard font dialog.

Use setCurrentFont() to set the initial font attributes.

The parent parameter is passed to the QDialog constructor.

See also:
getFont().


QFontDialog

public QFontDialog(QFont initial)
Constructs a standard font dialog with the given parent and specified initial color.


QFontDialog

public QFontDialog(QFont initial,
                   QWidget parent)
Constructs a standard font dialog with the given parent and specified initial color.

Method Detail

currentFont

public final QFont currentFont()

options

public final QFontDialog.FontDialogOptions options()
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).

See also:
setOption(), and testOption().


selectedFont

public final QFont selectedFont()
Returns the font that the user selected by clicking the OK or equivalent button.

Note: This font is not always the same as the font held by the currentFont property since the user can choose different fonts before finally selecting the one to use.


setCurrentFont

public final void setCurrentFont(QFont font)

setOption

public final void setOption(QFontDialog.FontDialogOption option)
Sets the given option to be enabled if on is true; otherwise, clears the given option.

See also:
options, and testOption().


setOption

public final void setOption(QFontDialog.FontDialogOption option,
                            boolean on)
Sets the given option to be enabled if on is true; otherwise, clears the given option.

See also:
options, and testOption().


setOptions

public final void setOptions(QFontDialog.FontDialogOption[] options)
This is an overloaded method provided for convenience.


setOptions

public final void setOptions(QFontDialog.FontDialogOptions options)
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).

See also:
setOption(), and testOption().


testOption

public final boolean testOption(QFontDialog.FontDialogOption option)
Returns true if the given option is enabled; otherwise, returns false.

See also:
options, and setOption().


getFont

public static QFontDialog.Result getFont(QFont initial,
                                         QWidget parent,
                                         java.lang.String title,
                                         QFontDialog.FontDialogOptions options)
This is an overloaded method provided for convenience.


getFont

public static QFontDialog.Result getFont(QFont initial,
                                         QWidget parent,
                                         java.lang.String caption)
Executes a modal font dialog and returns a font.

If the user clicks OK, the selected font is returned. If the user clicks Cancel, the initial font is returned.

The dialog is constructed with the given parent. caption is shown as the window title of the dialog and initial is the initially selected font.

This static function is less flexible than the full QFontDialog object, but is convenient and easy to use.


getFont

public static QFontDialog.Result getFont(QWidget parent)
This is an overloaded method provided for convenience.


getFont

public static QFontDialog.Result getFont()
This is an overloaded method provided for convenience.


getFont

public static QFontDialog.Result getFont(QFont initial,
                                         QWidget parent)
This is an overloaded method provided for convenience.


getFont

public static QFontDialog.Result getFont(QFont initial)
This is an overloaded method provided for convenience.