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

void QWidget::ensurePolished (  )  const [inherited]

Ensures that the widget has been polished by QStyle (i.e., has a proper font and palette).

QWidget calls this function after it has been fully constructed but before it is shown the very first time. You can call this function if you want to ensure that the widget is polished before doing an operation, e.g., the correct font size might be needed in the widget's sizeHint() reimplementation. Note that this function is called from the default implementation of sizeHint().

Polishing is useful for final initialization that must happen after all constructors (from base classes as well as from subclasses) have been called.

If you need to change some settings when a widget is polished, reimplement event() and handle the QEvent::Polish event type.

{Note:} The function is declared const so that it can be called from other const functions (e.g., sizeHint()).

See also:

Definition at line 7285 of file qwidget.cpp.

References QList< T >::at(), QWidget::ensurePolished(), QObject::isWidgetType(), QCoreApplication::sendEvent(), and QList< T >::size().

Referenced by QWidget::adjustSize(), QComboBox::changeEvent(), Q3ListBox::doLayout(), QWidget::ensurePolished(), QWidget::event(), QMdiSubWindow::event(), QMenuBar::minimumSizeHint(), QSplitter::minimumSizeHint(), QLabel::minimumSizeHint(), QMdiSubWindow::minimumSizeHint(), QCalendarWidget::minimumSizeHint(), QLineEdit::minimumSizeHint(), QAbstractSpinBox::minimumSizeHint(), QMenu::popup(), QWidget::showFullScreen(), QWidget::showMaximized(), QWidget::showMinimized(), QWidget::showNormal(), QMenuBar::sizeHint(), QProgressBar::sizeHint(), Q3Header::sizeHint(), Q3DateTimeEdit::sizeHint(), QCheckBox::sizeHint(), Q3TimeEdit::sizeHint(), Q3DateEdit::sizeHint(), Q3ListBox::sizeHint(), QPushButton::sizeHint(), QRadioButton::sizeHint(), QAbstractSpinBox::sizeHint(), QScrollBar::sizeHint(), Q3ListView::sizeHint(), QDateTimeEdit::sizeHint(), QSplitter::sizeHint(), Q3TextEdit::sizeHint(), QSlider::sizeHint(), QLineEdit::sizeHint(), Q3ProgressBar::sizeHint(), Q3IconView::sizeHint(), QMenu::sizeHint(), QToolButton::sizeHint(), QSplitter::sizes(), QLayout::totalHeightForWidth(), QLayout::totalMaximumSize(), QLayout::totalMinimumSize(), and QLayout::totalSizeHint().

    Q_D(const QWidget);

    const QMetaObject *m = metaObject();
    if (m == d->polished)
    d->polished = m;

    QEvent e(QEvent::Polish);
    QCoreApplication::sendEvent(const_cast<QWidget *>(this), &e);

    // polish children after 'this'
    QList<QObject*> children = d->children;
    for (int i = 0; i < children.size(); ++i) {
        QObject *o = children.at(i);
        if (QWidget *w = qobject_cast<QWidget *>(o))

    if (d->parent && d->sendChildEvents) {
        QChildEvent e(QEvent::ChildPolished, const_cast<QWidget *>(this));
        QCoreApplication::sendEvent(d->parent, &e);

Generated by  Doxygen 1.6.0   Back to index