[Interest] pre-processing for Qt widget stylesheet

Konstantin Tokarev annulen at yandex.ru
Wed Aug 12 15:21:53 CEST 2015



12.08.2015, 05:06, "Hamish Moffatt" <hamish at risingsoftware.com>:
> On 11/08/15 19:25, Konstantin Tokarev wrote:
>>  I've implemented custom SCSS-like markup using Text:Sass [1], it is not very strict
>>  about (S)CSS conformance and one can relatively easy write custom (non-CSS) generator
>>  (e.g., my code produces XML)
>>
>>  [1] http://search.cpan.org/~rpettett/Text-Sass-0.97/lib/Text/Sass.pm
>
> Thanks, but I want to do it at runtime (ie in the C++ app) as I will
> have some constants that depend on the runtime environment, eg the
> screen DPI.

1. You can pre-generate style sheets for all DPI values you are going to support and
choose the right file in run time.

2. It is not difficult to implement variable substitution yourself e.g. via
QByteArray::replace(). Capabilities of such "template engine" are quite limited as
compared to SASS/SCSS, but it would be much faster and would not require additional
libraries.

2b. With tool like re2c[1] one can implement more capable (and fast at the same time)
preprocessor than with simple string substitutions. re2c is quite handy to use but
requires some learning.

[1] http://re2c.sourceforge.net/

-- 
Regards,
Konstantin



More information about the Interest mailing list