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

QStyle * QApplication::style (  )  [static]

Returns the application's style object.

See also:
setStyle(), QStyle

Definition at line 1150 of file qapplication.cpp.

References QList< T >::at(), QStyleFactory::keys(), QStyle::polish(), setPalette(), QObject::setParent(), and QList< T >::size().

Referenced by QItemDelegate::check(), QItemDelegate::doLayout(), QItemDelegate::drawCheck(), QItemDelegate::drawDisplay(), QItemDelegate::drawFocus(), setActiveWindow(), setStyle(), QMessageBox::standardIcon(), and QItemDelegate::textRectangle().

{
    if (QApplicationPrivate::app_style)
        return QApplicationPrivate::app_style;
    if (!qt_is_gui_used)
        qFatal("No style available in non-gui applications!");

#if defined(Q_WS_X11)
    if(!QApplicationPrivate::styleOverride)
        QApplicationPrivate::x11_initialize_style(); // run-time search for default style
#endif
    if (!QApplicationPrivate::app_style) {
        // Compile-time search for default style
        //
        QString style;
        if (QApplicationPrivate::styleOverride) {
            style = *QApplicationPrivate::styleOverride;
            delete QApplicationPrivate::styleOverride;
            QApplicationPrivate::styleOverride = 0;
        } else {
#if defined(Q_WS_WIN) && defined(Q_OS_TEMP)
            style = QLatin1String("PocketPC");
#elif defined(Q_WS_WIN)
            if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
                && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
                style = QLatin1String("WindowsVista");
                else if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
                && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
                style = QLatin1String("WindowsXP");
            else
                style = QLatin1String("Windows");                // default styles for Windows
#elif defined(Q_WS_X11) && defined(Q_OS_SOLARIS)
            style = QLatin1String("CDE");                        // default style for X11 on Solaris
#elif defined(Q_WS_X11) && defined(Q_OS_IRIX)
            style = QLatin1String("SGI");                        // default style for X11 on IRIX
#elif defined(Q_WS_X11) || defined(Q_WS_QWS)
            style = QLatin1String("Plastique");                  // default style for X11 and small devices
#elif defined(Q_WS_MAC)
                style = QLatin1String("Macintosh");              // default style for all Mac's
#endif
        }

        QStyle *&app_style = QApplicationPrivate::app_style;
        app_style = QStyleFactory::create(style);
        if (!app_style) {
            QStringList styles = QStyleFactory::keys();
            for (int i = 0; i < styles.size(); ++i) {
                if ((app_style = QStyleFactory::create(styles.at(i))))
                    break;
            }
        }
        if (!app_style)
            qFatal("No styles available!");
    }
    // take ownership of the style
    QApplicationPrivate::app_style->setParent(qApp);

    if (!QApplicationPrivate::sys_pal)
        QApplicationPrivate::setSystemPalette(QApplicationPrivate::app_style->standardPalette());
    if (QApplicationPrivate::set_pal) // repolish set palette with the new style
        QApplication::setPalette(*QApplicationPrivate::set_pal);

#ifndef QT_NO_STYLE_STYLESHEET
    if (!QApplicationPrivate::styleSheet.isEmpty()) {
        qApp->setStyleSheet(QApplicationPrivate::styleSheet);
    } else
#endif
        QApplicationPrivate::app_style->polish(qApp);

    return QApplicationPrivate::app_style;
}


Generated by  Doxygen 1.6.0   Back to index