Qt Toolkit - QFontDialog Class

| Classes - Annotated - Tree - Functions - Home - Structure

# QFontDialog Class Reference

The QFontDialog class provides a dialog widget for selecting a text font. More...

`#include <qfontdialog.h>`

Inherits QDialog.

List of all member functions.

## Signals

- void fontSelected ( const QFont & font )
- void fontHighlighted ( const QFont & font )

## Static Public Members

- QFont getFont ( bool * ok, const QFont & def, QWidget * parent = 0, const char * name = 0 )
- QFont getFont ( bool * ok, QWidget * parent = 0, const char * name = 0 )

## Protected Members

- virtual bool eventFilter ( QObject *, QEvent * )
- QListBox* familyListBox () const
- virtual void updateFamilies ()
- QListBox* styleListBox () const
- virtual void updateStyles ()
- QListBox* sizeListBox () const
- virtual void updateSizes ()
- QComboBox* scriptCombo () const
- virtual void updateScripts ()

## Protected Slots

- void sizeChanged ( const QString & )

## Detailed Description

The QFontDialog class provides a dialog widget for selecting a text font.

This dialog can be used to let the user choose a font with attributes and so on. Normally you may use the static convenience function getFont().

## Member Function Documentation

### bool QFontDialog::eventFilter ( QObject * o, QEvent * e ) `[virtual protected]`

Event filter to make up, down, pageup and pagedown work correctly in the line edits.

Reimplemented from QObject.

### QListBox * QFontDialog::familyListBox () const `[protected]`

Returns a pointer to the "font family" list box. This is usable mainly if you reimplement updateFontFamilies();.

### void QFontDialog::fontHighlighted ( const QFont & ) `[signal]`

This signal is emitted, when the user changed a setting in the dialog.

### void QFontDialog::fontSelected ( const QFont & ) `[signal]`

This signal is emitted, when the user has chosen a font and clicked ok.

### QFont QFontDialog::getFont ( bool * ok, QWidget * parent = 0,const char * name = 0 ) `[static]`

Opens a modal font dialog and returns the font selected by the user.

The ok parameter is set to TRUE if the user clicked OK, and FALSE if the user clicked Cancel.

If the user clicks Cancel the Qt default font is returned.

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

Example:

        // start at the current working directory and with *.cpp as filter
        bool ok;
        QFont f = QFontDialog::getFont( &ok, this );
        if ( ok ) {
            // the user selected a valid font
        } else {
            // the user cancelled the dialog
        }

### QFont QFontDialog::getFont ( bool * ok, const QFont & initial, QWidget * parent = 0, const char * name = 0 ) `[static]`

Opens a modal font dialog and returns the font selected by the user.

initial is the initial selected font.

The ok parameter is set to TRUE if the user clicked OK, and FALSE if the user clicked Cancel.

If the user clicks Cancel the initial font is returned.

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

Example:

        // start at the current working directory and with *.cpp as filter
        bool ok;
        QFont f = QFontDialog::getFont( &ok, QFont( "Times", 12 ), this );
        if ( ok ) {
            // the user selected a valid font
        } else {
            // the user cancelled the dialog
        }

Another example:

        mywidget.setFont( QFontDialog::getFont( 0, mywidget.font() ) );

### QComboBox * QFontDialog::scriptCombo () const `[protected]`

Returns a pointer to the "font style" list box. This is usable mainly if you reimplement updateFontStyles();.

### void QFontDialog::sizeChanged ( const QString & s ) `[protected slot]`

This slot is called if the user changes the font size.

### QListBox * QFontDialog::sizeListBox () const `[protected]`

Returns a pointer to the "font size" list box. This is usable mainly if you reimplement updateFontSizes();.

### QListBox * QFontDialog::styleListBox () const `[protected]`

Returns a pointer to the "font style" list box. This is usable mainly if you reimplement updateFontStyles();.

### void QFontDialog::updateFamilies () `[virtual protected]`

Update the contents of the "font family" list box. This function can be reimplemented if you have special requirements.

### void QFontDialog::updateScripts () `[virtual protected]`

Update the contents of the "font script" combo box. This function can be reimplemented if you have special requirements.

### void QFontDialog::updateSizes () `[virtual protected]`

Update the contents of the "font size" list box. This function can be reimplemented if you have special requirements.

### void QFontDialog::updateStyles () `[virtual protected]`

Update the contents of the "font style" list box. This function can be reimplemented if you have special requirements.

Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):

This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.