PDA

View Full Version : Dynamic Translation of resource based images used for style sheet ?



rantanplan
10th February 2011, 15:34
I'm modifying a splitter handle by assigning an image from a resource.


setStyleSheet(QString("QSplitter::handle {image: url(:/images/zoom-in.png)} \
QSplitter::handle:pressed {image: url(:/images/star.png)}"));

The resource file uses locale dependent aliases.

<RCC>
<qresource prefix="images">
<file>star.png</file>
<file>zoom-in.png</file>
</qresource>
<qresource prefix="images" lang="de">
<file alias="star.png">star_de.png</file>
<file alias="zoom-in.png">zoom-in_de.png</file>
</qresource>
<qresource prefix="images" lang="en">
<file alias="star.png">star_en.png</file>
<file alias="zoom-in.png">zoom-in_en.png</file>
</qresource>
</RCC>

This works fine as long as I do a QLocale::setDefault() at application launch (main).
Questions: Is it possible to make the style sheet consider the different images
when changing the language/locale at runtime ?

Joerg

wysota
10th February 2011, 20:32
Stylesheet is evaluated only once when it is applied.If you want to re-evaluate it you need to set (the same) stylesheet again.