Logo Search packages:      
Sourcecode: qt4-x11 version File versions  Download package

const QFont & QWidget::font [inline, read, write, inherited]

the font currently set for the widget

The fontInfo() function reports the actual font that is being used by the widget.

As long as no special font has been set, or after setFont(QFont()) is called, this is either a special font for the widget class, the parent's font or (if this widget is a top level widget), the default application font.

This code fragment sets a 12 point helvetica bold font:

doc/src/snippets/code/src_gui_kernel_qwidget.cpp 4

Note that when a child widget is given a different font to that of its parent widget, it will still inherit the parent's font properties unless these have been set explicitly on the child's font. For example, if the parent's font is bold, the child widget's font will be bold as well if not specified otherwise like this:

doc/src/snippets/code/src_gui_kernel_qwidget.cpp 5

In addition to setting the font, setFont() informs all children about the change.

If {Qt Style Sheets} are used on the same widget as setFont(), style sheets will take precedence if the settings conflict.
See also:
fontInfo() fontMetrics()

Reimplemented in Window.

Definition at line 167 of file qwidget.h.

Referenced by Q3Table::adjustColumn(), Calculator::Calculator(), QLabel::changeEvent(), QMessageBox::changeEvent(), QComboBox::changeEvent(), QTextEdit::changeEvent(), Q3IconView::changeEvent(), QPlainTextEdit::changeEvent(), Q3IconView::drawContents(), Q3ListView::drawContentsOffset(), GLWidget::drawInstructions(), QMdiSubWindow::event(), Q3TextEdit::font(), MainWindow::handleFontChange(), PieView::indexAt(), QPainter::initFrom(), QToolButton::initStyleOption(), QLineEdit::inputMethodQuery(), QWebPage::inputMethodQuery(), MainWindow::itemSelected(), Q3TextEdit::optimAppend(), Q3TextEdit::optimCharIndex(), Q3TextEdit::optimDoAutoScroll(), Q3TextEdit::optimDrawContents(), Q3TextEdit::optimFind(), Q3TextEdit::optimInsert(), Q3TextEdit::optimMousePressEvent(), Q3TextEdit::optimMouseReleaseEvent(), Q3TextEdit::optimSetText(), WigglyWidget::paintEvent(), Q3ComboBox::paintEvent(), Q3CheckListItem::paintFocus(), Q3TextEdit::paragraphAt(), QWindowsVistaStyle::polish(), Q3ComboBox::popup(), Q3ComboBox::Q3ComboBox(), Q3IconView::Q3IconView(), QHeaderView::sectionSizeFromContents(), Q3ComboBox::setListBox(), MainWindow::setupEditor(), Q3TimeEdit::sizeHint(), Q3DateEdit::sizeHint(), QLineEdit::sizeHint(), QCleanlooksStyle::subControlRect(), Q3TextEdit::sync(), TextEdit::TextEdit(), QWindowsVistaStyle::unpolish(), QAbstractItemView::viewOptions(), WigglyWidget::WigglyWidget(), QTextEdit::zoomIn(), Q3TextEdit::zoomIn(), Q3TextEdit::zoomOut(), and Q3TextEdit::zoomTo().

Generated by  Doxygen 1.6.0   Back to index