[Qt-interest] Detect os in Qt StyleSheets?
Sean Harmer
sean.harmer at maps-technology.com
Fri Oct 15 10:58:40 CEST 2010
On Friday 15 October 2010 08:35:48 NoRulez wrote:
> Hello,
>
> Is there a way to do something like
> QLineEdit[os=macosx] { color: red; }
> QLineEdit[os=winxp,linux] { color: green; }
> QLineEdit[os=win7] { color: blue; }
Not within the stylesheet itself but it is trivial to load a platform-specific
stylesheet within your application. For e.g.
...
#ifdef Q_WS_WIN
QString stylesheet( "style-win.css" );
#elif Q_WS_X11
QString stylesheet( "style-linux.css" );
#elif
...
#endif
QFile file( stylesheet );
file.open( QIODevice::ReadOnly | QIODevice::Text );
QTextStream stream( &file );
QString cssText = stream.readAll();
qApp->setStyleSheet( "cssText" );
Or you can simply launch your application passing in the correct stylesheet as
a command line argument:
./myapp -stylesheet style-linux.css
HTH,
Sean
More information about the Qt-interest-old
mailing list