使用“少"或类似的东西来生成Qt样式表 [英] Use "Less" or something similar to generate a Qt Stylesheets

查看:114
本文介绍了使用“少"或类似的东西来生成Qt样式表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的 Qt 应用程序创建样式表,以自定义外观.我很想利用CSS生成器,例如 LESS

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.

我担心的是Qt并未将W3C标准用于样式表,而是使用了子集语法以及一些其他选项.

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.

这甚至有可能吗? Less and Compass是否能够生成有效的 Qt样式表?

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

推荐答案

Qt的CSS具有一些特殊性,可防止直接使用经典的LESS或SASS编译器(选择器,渐变函数中的!").我也有同样的需求,所以我想出了这个工具: https://github.com/yann-lty /qtsass .

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.

这是一个轻量级的实用程序,它通过处理两个规范之间的差异(自述文件中提供了信息),将W3C有效的SASS文件转换为有效的Qt样式表.请注意,它目前正在开发中,可能无法涵盖所有​​内容.但是我一直在生产中使用它,这是一个很好的起点.

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.

这篇关于使用“少"或类似的东西来生成Qt样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆