简体   繁体   English

PyQt4中的CSS显示错误

[英]CSS in PyQt4 showing error

I came to know that we can use CSS stylings in PyQt but I am not able to use all the CSS code effectively... 我知道我们可以在PyQt中使用CSS样式,但是我不能有效地使用所有CSS代码...

when I try this code ..(all the remaining code is correct..) 当我尝试此代码时..(其余所有代码都是正确的..)

QPushButton { transition: opacity 1s ease-in-out; box-shadow: 0px 1px 0px 0px #fff6af; background-color:#ffec64; border-radius:6px; border:1px solid #ffaa22; display:inline-block; cursor:pointer; color:#000000; text-decoration:none; text-shadow:0px 1px 0px #ffee66; }

I get the following error 我收到以下错误

Unknown property transition
Unknown property box-shadow
Unknown property display
Unknown property cursor
Unknown property text-shadow

Is there any way I can use all these properties i pyqt application...? 有什么办法可以在pyqt应用程序中使用所有这些属性...?

I believe you can't set these properties using QSS and you should look for alternatives to set this properties. 我相信您不能使用QSS设置这些属性,而应该寻找替代方法来设置此属性。 For instance, to change the cursor to pointer you can do the following: 例如,要将光标更改为指针,可以执行以下操作:

self.setCursor(QtCore.Qt.PointingHandCursor)

You can find the various cursors that can be used here . 您可以在此处找到可以使用的各种游标。

Not all CSS properties are supported in QSS, and there are also some additional properties which are specific to Qt. QSS并不支持所有CSS属性,并且还有一些特定于Qt的其他属性。 Also, the set of supported properties is not available for all widgets. 另外,并非所有窗口小部件都支持受支持的属性集。

To see what's supported, see the List of Properties in the Style Sheets Reference . 要查看支持的内容,请参见《 样式表参考》中 的“属性列表” You should probably also take a look at the Style Sheets Overview and the Style Sheet Syntax guide. 您可能还应该看看样式表概述样式表语法指南。

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

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