简体   繁体   English

使用“少”或类似的东西来生成一个Qt样式表

[英]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. 我正在为Qt应用程序创建样式表以自定义外观。 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. 我很想利用CSS生成器(如LESSCompass) ,因此我至少可以将变量用于颜色,并可以利用它们提供的其他一些出色功能。

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. 我担心的是,Qt并未将W3C标准用于样式表,而是使用了语法的子集以及一些其他选项。

Is this even possible? 这有可能吗? Are Less and Compass able to generate valid Qt stylesheets ? Less和Compass是否能够生成有效的Qt样式表

Qt's CSS has a few specificities that prevent the direct use of a classic LESS or SASS compiler ("!" in selectors, gradient functions...). Qt的CSS具有一些特殊性,可防止直接使用经典的LESS或SASS编译器(选择器,渐变函数中的“!”)。 I had the same need, so I came up with this tool: https://github.com/yann-lty/qtsass . 我也有同样的需求,所以我想到了这个工具: 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). 它是一个轻量级实用程序,可通过处理两个规范之间的差异(自述文件中记录),将W3C有效的SASS文件转换为有效的Qt样式表。 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. 但是我一直在生产中使用它,这是一个很好的起点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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