qt识别html style,css - Setting styles in Qt QLabels via style sheets and HTML classes - Stack Overflow...

在Python/Qt4.8 GUI中,作者尝试通过CSS类来为QLabel内的表格元素设置不同颜色,但遇到了Qtd不识别类选择器的问题。尽管可以使用全局标签进行样式修改,但作者希望实现更精确的样式控制。问题在于Qt的样式系统可能不支持CSS类选择器,导致部分样式无法应用。
摘要由CSDN通过智能技术生成

I have a QLabel in my Python/Qt 4.8 GUI, which contains a table. I'd like to style elements of this table with different colours. I realise I can use tags but it seems a little more elegant to use classes and CSS. I want it to look like this:

TYApD.png

My HTML looks like this:

Wavelength:{0:.2f} µm
Bandwidth:{1:.2f} µm
Power:{2:.1f} mW
{3:.0f} sec stability:{4:.1%} rms
{5:.1%} p2p

And my CSS like this:

#oldPM {color: #333333}

#spec {color: blue}

#newPM {color: #333333}

But Qt doesn't seem to recognise the class selectors. Is this a fundamental limitation of the Qt styling, or am I doing something wrong? I can get it to change the style of the whole QLabel, using QLabel as a selector, but I want different parts of it to be styled differently.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值