Qt Jambi Home

com.trolltech.qt.gui
Class QFontComboBox

java.lang.Object
  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.QComboBox
                      extended by com.trolltech.qt.gui.QFontComboBox
All Implemented Interfaces:
QPaintDeviceInterface, QtJambiInterface

public class QFontComboBox
extends QComboBox

The QFontComboBox widget is a combobox that lets the user select a font family.

The combobox is populated with an alphabetized list of font family names, such as Arial, Helvetica, and Times New Roman. Family names are displayed using the actual font when possible. For fonts such as Symbol, where the name is not representable in the font itself, a sample of the font is displayed next to the family name.

QFontComboBox is often used in toolbars, in conjunction with a QComboBox for controlling the font size and two QToolButtons for bold and italic.

When the user selects a new font, the currentFontChanged signal is emitted in addition to currentIndexChanged.

Call setWritingSystem to tell QFontComboBox to show only fonts that support a given writing system, and setFontFilters to filter out certain types of fonts as e.g. non scalable fonts or monospaced fonts.

Screenshot of QFontComboBox on Windows XP

See Also:
QComboBox, QFont, QFontInfo, QFontMetrics, QFontDatabase, Map Example

Nested Class Summary
static class QFontComboBox.FontFilter
          This enum can be used to only show certain types of fonts in the font combo box.
static class QFontComboBox.FontFilters
          This QFlag class provides flags for the int enum.
 
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QComboBox
QComboBox.InsertPolicy, QComboBox.SizeAdjustPolicy
 
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.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Field Summary
 QSignalEmitter.Signal1<QFont> currentFontChanged
          This signal is emitted whenever the current font changes, with the new f.
 
Fields inherited from class com.trolltech.qt.gui.QComboBox
activated, activatedIndex, currentIndexChanged, currentStringChanged, editTextChanged, highlighted, highlightedIndex
 
Fields inherited from class com.trolltech.qt.gui.QWidget
customContextMenuRequested
 
Constructor Summary
QFontComboBox()
          Equivalent to QFontComboBox(0).
QFontComboBox(QWidget parent)
          Constructs a font combobox with the given parent.
 
Method Summary
 QFont currentFont()
          Returns the currently selected font.
 boolean event(QEvent e)
          

This is the main event handler; it handles event arg__1. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

Key press and release events are treated differently from other events. event checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event calls keyPressEvent.

Mouse and tablet event handling is also slightly special: only when the widget is enabled, event will call the specialized handlers such as mousePressEvent; otherwise it will discard the event.

This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.

 QFontComboBox.FontFilters fontFilters()
          Returns the filter for the combobox.
static QFontComboBox fromNativePointer(QNativePointer nativePointer)
          This function returns the QFontComboBox instance pointed to by nativePointer
 void setCurrentFont(QFont f)
          Sets the currently selected font to f.
 void setFontFilters(QFontComboBox.FontFilter... filters)
          Sets the filter for the combobox to filters.
 void setFontFilters(QFontComboBox.FontFilters filters)
          Sets the filter for the combobox to filters.
 void setWritingSystem(QFontDatabase.WritingSystem arg__1)
          Sets the writing system that serves as a filter for the combobox to arg__1.
 QSize sizeHint()
          

Returns the recommended size for the widget.

If the value of this property is an invalid size, no size is recommended.

The default implementation of sizeHint returns an invalid size if there is no layout for this widget, and returns the layout's preferred size otherwise.

 QFontDatabase.WritingSystem writingSystem()
          Returns the writing system that serves as a filter for the combobox.
 
Methods inherited from class com.trolltech.qt.gui.QComboBox
addItem, addItem, addItem, addItem, addItems, changeEvent, clear, clearEditText, completer, contextMenuEvent, count, currentIndex, currentText, duplicatesEnabled, findData, findData, findData, findData, findText, findText, findText, focusInEvent, focusOutEvent, hasFrame, hideEvent, hidePopup, iconSize, initStyleOption, inputMethodEvent, inputMethodQuery, insertItem, insertItem, insertItem, insertItem, insertItems, insertPolicy, isEditable, itemData, itemData, itemDelegate, itemIcon, itemText, keyPressEvent, keyReleaseEvent, lineEdit, maxCount, maxVisibleItems, minimumContentsLength, minimumSizeHint, model, modelColumn, mousePressEvent, mouseReleaseEvent, paintEvent, removeItem, resizeEvent, rootModelIndex, setCompleter, setCurrentIndex, setDuplicatesEnabled, setEditable, setEditText, setFrame, setIconSize, setInsertPolicy, setItemData, setItemData, setItemDelegate, setItemIcon, setItemText, setLineEdit, setMaxCount, setMaxVisibleItems, setMinimumContentsLength, setModel, setModelColumn, setRootModelIndex, setSizeAdjustPolicy, setValidator, setView, showEvent, showPopup, sizeAdjustPolicy, validator, view, wheelEvent
 
Methods inherited from class com.trolltech.qt.gui.QWidget
acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuPolicy, createWinId, cursor, depth, destroy, destroy, destroy, devType, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, ensurePolished, enterEvent, focusNextChild, focusNextPrevChild, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, inputContext, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isLeftToRight, isMaximized, isMinimized, isModal, isRightToLeft, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, move, move, moveEvent, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, overrideWindowState, paintEngine, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, 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, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, width, widthMM, window, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

currentFontChanged

public final QSignalEmitter.Signal1<QFont> currentFontChanged

This signal is emitted whenever the current font changes, with the new f.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QFont f)
void mySlot()
See Also:
currentFont

Constructor Detail

QFontComboBox

public QFontComboBox()

Equivalent to QFontComboBox(0).


QFontComboBox

public QFontComboBox(QWidget parent)

Constructs a font combobox with the given parent.

Method Detail

currentFont

public final QFont currentFont()

Returns the currently selected font.

See Also:
setCurrentFont, currentFontChanged, currentIndex, currentText

fontFilters

public final QFontComboBox.FontFilters fontFilters()

Returns the filter for the combobox.

By default, all fonts are listed.

See Also:
setFontFilters, writingSystem

setCurrentFont

public final void setCurrentFont(QFont f)

Sets the currently selected font to f.

See Also:
currentFontChanged, currentIndex, currentText

setFontFilters

public final void setFontFilters(QFontComboBox.FontFilter... filters)

Sets the filter for the combobox to filters.

By default, all fonts are listed.

See Also:
fontFilters, writingSystem

setFontFilters

public final void setFontFilters(QFontComboBox.FontFilters filters)

Sets the filter for the combobox to filters.

By default, all fonts are listed.

See Also:
fontFilters, writingSystem

setWritingSystem

public final void setWritingSystem(QFontDatabase.WritingSystem arg__1)

Sets the writing system that serves as a filter for the combobox to arg__1.

If script is QFontDatabase::Any (the default), all fonts are listed.

See Also:
writingSystem, fontFilters

writingSystem

public final QFontDatabase.WritingSystem writingSystem()

Returns the writing system that serves as a filter for the combobox.

If script is QFontDatabase::Any (the default), all fonts are listed.

See Also:
setWritingSystem, fontFilters

event

public boolean event(QEvent e)

This is the main event handler; it handles event arg__1. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

Key press and release events are treated differently from other events. event checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event calls keyPressEvent.

Mouse and tablet event handling is also slightly special: only when the widget is enabled, event will call the specialized handlers such as mousePressEvent; otherwise it will discard the event.

This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.

Overrides:
event in class QComboBox
See Also:
closeEvent, focusInEvent, focusOutEvent, enterEvent, keyPressEvent, keyReleaseEvent, leaveEvent, mouseDoubleClickEvent, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, moveEvent, paintEvent, resizeEvent, QObject::event, QObject::timerEvent

sizeHint

public QSize sizeHint()

Returns the recommended size for the widget.

If the value of this property is an invalid size, no size is recommended.

The default implementation of sizeHint returns an invalid size if there is no layout for this widget, and returns the layout's preferred size otherwise.

Overrides:
sizeHint in class QComboBox
See Also:
QSize::isValid, minimumSizeHint, sizePolicy, setMinimumSize, updateGeometry

fromNativePointer

public static QFontComboBox fromNativePointer(QNativePointer nativePointer)
This function returns the QFontComboBox instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

Qt Jambi Home