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

void QWidget::setStyle ( QStyle style  )  [inherited]

Sets the widget's GUI style to style. The ownership of the style object is not transferred.

If no style is set, the widget uses the application's style, QApplication::style() instead.

Setting a widget's style has no effect on existing or future child widgets.

Warning:
This function is particularly useful for demonstration purposes, where you want to show Qt's styling capabilities. Real applications should avoid it and use one consistent GUI style instead.

Qt style sheets are currently not supported for custom QStyle subclasses. We plan to address this in some future release.

See also:
style(), QStyle, QApplication::style(), QApplication::setStyle()

Definition at line 2310 of file qwidget.cpp.

References QWidget::setAttribute().

Referenced by QDialogButtonBox::changeEvent().

{
    Q_D(QWidget);
    setAttribute(Qt::WA_SetStyle, style != 0);
    d->createExtra();
#ifndef QT_NO_STYLE_STYLESHEET
    if (QStyleSheetStyle *proxy = qobject_cast<QStyleSheetStyle *>(style)) {
        //if for some reason someone try to set a QStyleSheetStyle, ref it
        //(this may happen for exemple in QButtonDialogBox which propagates its style)
        proxy->ref();
        d->setStyle_helper(style, false);
    } else if (qobject_cast<QStyleSheetStyle *>(d->extra->style) || !qApp->styleSheet().isEmpty()) {
        // if we have an application stylesheet or have a proxy already, propagate
        d->setStyle_helper(new QStyleSheetStyle(style), true);
    } else
#endif
        d->setStyle_helper(style, false);
}


Generated by  Doxygen 1.6.0   Back to index