0

I'm creating a stylesheet for my Qt application to customize the look and feel. I'd love to take advantage of a CSS generator like LESS or Compass, so I can at least use variables for color and perhaps take advantage of some of the other cool features they offer.

My concern is that Qt does not use the W3C standard for stylesheet, they utilize a subset of the syntax with a few extra options.

Is this even possible? Are Less and Compass able to generate valid Qt stylesheets?

Matt
  • 1,415
  • 2
  • 15
  • 23
  • 1
    Both Less and Sass (note that Compass is just a framework on top of Sass and not some kind of distinct language/translator) are identifier agnostic (simply because CSS itself also is). I.e. anything like `Whatever {foo: bar fnord}` is valid there, so in general it should be no problems with QT specific selectors, properties and values (unless there's something that directly violates CSS syntax). – seven-phases-max Aug 10 '15 at 20:26
  • Related/duplicate: https://stackoverflow.com/questions/10898399/using-variables-in-qt-stylesheets – Maxim Paperno Sep 15 '19 at 02:49

1 Answers1

3

Qt's CSS has a few specificities that prevent the direct use of a classic LESS or SASS compiler ("!" in selectors, gradient functions...). I had the same need, so I came up with this tool: https://github.com/yann-lty/qtsass.

It's a lightweight utility that turns a W3C-valid SASS file into a valid Qt stylesheet by handling the variations between the two specifications (documented in the README file). Note that it is currently under development and might not cover everything; but I've been using it in production and it's a good starting point.

yann-lty
  • 31
  • 3