简体   繁体   中英

Use “Less” or something similar to generate a Qt Stylesheets

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM