Remove QComboBox listView shadow effect

自闭症网瘾萝莉.ら 提交于 2019-12-01 19:19:36

The shadow effect is not a Qt specific thing, its a Desktop theme specific thing. The shadow depends on the style/theme your desktop environment is using. If your style/theme defines shadows for QComboBox then Qt will very promptly draw it. That said, you may search for a style that does not draw a shadow. I got the effect by doing so:

cb = QComboBox()
cb.addItems( [ '1', '2', '3', '4', '5', '6' ] )
cb.setStyle( QStyleFactory.create( "Polyester" ) )
cb.setStyleSheet( "QComboBox QAbstractItemView { border: 1 px solid gray; }" )
cb.show()

For this, you must have a compatible theme like polyester listed by QStyleFactory.keys(). I tried with the snazzy Breeze style and the famous QtCurve style, but they draws a shadow always. You may achieve the same using GTK+ and the Cleanlooks styles.

FYI: Polyester is one of the styles that comes with KDE.

Here is a screenshot of the above code:

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!