void WidgetGallery::changeStyle(const QString &styleName){ if (styleName == "NorwegianWood") { QApplication::setStyle(new NorwegianWoodStyle); } else { QApplication::setStyle(QStyleFactory::create(styleName)); } changePalette();}
#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!"); }
QStyle SystemStyle( *(QApplication::style()) );
QString defaultStyle = QApplication::style()->objectName(); QApplication::setStyle(new QCleanlooksStyle); QApplication::setStyle(defaultStyle);