/*! Creates and returns a QStyle object that matches the given \a key, or returns 0 if no matching style is found. Both built-in styles and styles from style plugins are queried for a matching style. \note The keys used are case insensitive. \sa keys() */ QStyle *QStyleFactory::create(const QString& key) { QStyle *ret = 0; QString style = key.toLower(); #ifndef QT_NO_STYLE_WINDOWS if (style == QLatin1String("windows")) ret = new QWindowsStyle; else #endif #ifndef QT_NO_STYLE_WINDOWSCE if (style == QLatin1String("windowsce")) ret = new QWindowsCEStyle; else #endif #ifndef QT_NO_STYLE_WINDOWSMOBILE if (style == QLatin1String("windowsmobile")) ret = new QWindowsMobileStyle; else #endif #ifndef QT_NO_STYLE_WINDOWSXP if (style == QLatin1String("windowsxp")) ret = new QWindowsXPStyle; else #endif #ifndef QT_NO_STYLE_WINDOWSVISTA if (style == QLatin1String("windowsvista")) ret = new QWindowsVistaStyle; else #endif #ifndef QT_NO_STYLE_FUSION if (style == QLatin1String("fusion")) ret = new QFusionStyle; else #endif #ifndef QT_NO_STYLE_GTK if (style == QLatin1String("gtk") || style == QLatin1String("gtk+")) ret = new QGtkStyle; else #endif #ifndef QT_NO_STYLE_MAC if (style.startsWith(QLatin1String("macintosh"))) { ret = new QMacStyle; # ifdef Q_WS_MAC if (style == QLatin1String("macintosh")) style += QLatin1String(" (aqua)"); # endif } else #endif { } // Keep these here - they make the #ifdefery above work #ifndef QT_NO_LIBRARY if (!ret) ret = qLoadPlugin<QStyle, QStylePlugin>(loader(), style); #endif if(ret) ret->setObjectName(style); return ret; }
/*! Creates and returns a QStyle object that matches the given \a key, or returns 0 if no matching style is found. Both built-in styles and styles from style plugins are queried for a matching style. \note The keys used are case insensitive. \sa keys() */ QStyle *QStyleFactory::create(const QString& key) { QStyle *ret = Q_NULLPTR; QString style = key.toLower(); #ifndef QT_NO_STYLE_WINDOWS if (style == QLatin1String("windows")) ret = new QWindowsStyle; else #endif #ifndef QT_NO_STYLE_MOTIF if (style == QLatin1String("motif")) ret = new QMotifStyle; else #endif #ifndef QT_NO_STYLE_CDE if (style == QLatin1String("cde")) ret = new QCDEStyle; else #endif #ifndef QT_NO_STYLE_PLASTIQUE if (style == QLatin1String("plastique")) ret = new QPlastiqueStyle; else #endif #ifndef QT_NO_STYLE_CLEANLOOKS if (style == QLatin1String("cleanlooks")) ret = new QCleanlooksStyle; else #endif #ifndef QT_NO_STYLE_GTK if (style == QLatin1String("gtk") || style == QLatin1String("gtk+")) ret = new QGtkStyle; else #endif { } // Keep these here - they make the #ifdefery above work #if !defined(QT_NO_LIBRARY) && !defined(QT_NO_SETTINGS) if(!ret) { if (QStyleFactoryInterface *factory = qobject_cast<QStyleFactoryInterface*>(stylesloader()->instance(style))) ret = factory->create(style); } #endif if(ret) ret->setObjectName(style); return ret; }
int load_style(QString &path, QString &name) { int ret = 0; QStyle *s; QPluginLoader pl(path); QObject *o = pl.instance(); if (o != 0) { QStylePlugin *sp = qobject_cast<QStylePlugin *>(o); if (sp != 0) { s = sp->create(name); if (s != 0) { s->setObjectName(name); QApplication::setStyle(s); ret = 1; } } } return ret; }
/*! Creates and returns a QStyle object that matches the given \a key, or returns 0 if no matching style is found. Both built-in styles and styles from style plugins are queried for a matching style. \note The keys used are case insensitive. \sa keys() */ QStyle *QStyleFactory::create(const QString& key) { QStyle *ret = 0; QString style = key.toLower(); #ifndef QT_NO_STYLE_WINDOWS if (style == QLatin1String("windows")) ret = new QWindowsStyle; else #endif #ifndef QT_NO_STYLE_WINDOWSXP if (style == QLatin1String("windowsxp")) ret = new QWindowsXPStyle; else #endif #ifndef QT_NO_STYLE_WINDOWSVISTA if (style == QLatin1String("windowsvista")) ret = new QWindowsVistaStyle; else #endif #ifndef QT_NO_STYLE_MOTIF if (style == QLatin1String("motif")) ret = new QMotifStyle; else #endif #ifndef QT_NO_STYLE_CDE if (style == QLatin1String("cde")) ret = new QCDEStyle; else #endif #ifndef QT_NO_STYLE_PLASTIQUE if (style == QLatin1String("plastique")) ret = new QPlastiqueStyle; else #endif #ifndef QT_NO_STYLE_CLEANLOOKS if (style == QLatin1String("cleanlooks")) ret = new QCleanlooksStyle; else #endif #ifndef QT_NO_STYLE_GTK if (style == QLatin1String("gtk") || style == QLatin1String("gtk+")) ret = new QGtkStyle; else #endif #ifndef QT_NO_STYLE_MAC if (style.startsWith(QLatin1String("macintosh"))) { ret = new QMacStyle; # ifdef Q_WS_MAC if (style == QLatin1String("macintosh")) style += QLatin1String(" (aqua)"); # endif } else #endif { } // Keep these here - they make the #ifdefery above work #if ! defined(QT_NO_SETTINGS) if(!ret) { if (QStyleFactoryInterface *factory = qobject_cast<QStyleFactoryInterface*>(loader()->instance(style))) ret = factory->create(style); } #endif if(ret) ret->setObjectName(style); return ret; }