qtstylesheets

Set a StyleSheet for a whole widget in Qt

冷暖自知 提交于 2021-02-19 03:58:05
问题 I have a custom widget which inherits from QWidget and contains some labels in its layout. I would like to change the background color of the widget and the labels in the widget (this is, everything!) every time I put the mouse over it. When using *:hover { background: red; } in my custom widget, I only get the contents red when moving the mouse over the labels, but not outside them, between labels, etc. I don't understand this behavior taking into account that I put the StyleSheet in the

Parsing property values from stylesheet for drawing custom widgets

一笑奈何 提交于 2021-02-05 11:20:07
问题 I have to create a couple of custom qt widgets, some of which use custom drawing. Those widgets should be styled via the companies qt stylesheet. This creates the problem that some custom widget need to retrieve a value from stylesheet that has been applied to the QMainWindow or QApplication . This value could either be one of qt's official properties or some custom qproperty-... property However, it is not trivial to access them from the widget. One option would be to get the stylesheet

Changing the spacing between QTableView cells using stylesheet in PyQt5

喜夏-厌秋 提交于 2021-01-20 11:57:10
问题 How to add spaces between table cells using QSS selectors. I've tried the border-spacing selector, the item pseudo-class with the border selector, but it all doesn't work as it should. Here is a sample code that I thought was supposed to do this. app. setStyleSheet ("QTableView { border-collapse: separate; border-spacing: 10px 20px; color: red;}") Here's a picture of what I mean. 回答1: With style-sheets, you are either able to separate the individual cells via border-spacing (as in your

Stylesheet does not work properly in PyQt

情到浓时终转凉″ 提交于 2021-01-07 02:54:23
问题 I am trying to build an app using PyQt, so I decided to first develop the UI using qt Designer. I want to style my elements, so I am using stylesheets to specify the styles I need. After making the UI in qt Designer, I used the preview button to see if everything works, and everything was working as expected. Then, I used pyuic5 to convert the UI file to the python version. Now, almost everything is OK, but SOME stylesheets do not work properly. For example, I used stylesheet for QComboBox,

Stylesheet does not work properly in PyQt

浪尽此生 提交于 2021-01-07 02:53:38
问题 I am trying to build an app using PyQt, so I decided to first develop the UI using qt Designer. I want to style my elements, so I am using stylesheets to specify the styles I need. After making the UI in qt Designer, I used the preview button to see if everything works, and everything was working as expected. Then, I used pyuic5 to convert the UI file to the python version. Now, almost everything is OK, but SOME stylesheets do not work properly. For example, I used stylesheet for QComboBox,

how to style the QScrollBar when the content is not scrolling?

ぃ、小莉子 提交于 2020-12-12 04:59:46
问题 I want to style the scrollbars. I am able to apply styles to scrollbar when scrollarea content is scrolling. But when the content is not scrolling the style is not getting applied to it. I have used below style elements: QScrollBar:vertical{ /** some styles **/ }; QScrollBar::handle:vertical{ /** some styles **/ }; QScrollBar::add-line:vertical{ /** some styles **/ }; QScrollBar::sub-line:vertical{ /** some styles **/ }; QScrollBar::add-page:vertical{ /** some styles **/ }; QScrollBar::sub

how to style the QScrollBar when the content is not scrolling?

人走茶凉 提交于 2020-12-12 04:59:06
问题 I want to style the scrollbars. I am able to apply styles to scrollbar when scrollarea content is scrolling. But when the content is not scrolling the style is not getting applied to it. I have used below style elements: QScrollBar:vertical{ /** some styles **/ }; QScrollBar::handle:vertical{ /** some styles **/ }; QScrollBar::add-line:vertical{ /** some styles **/ }; QScrollBar::sub-line:vertical{ /** some styles **/ }; QScrollBar::add-page:vertical{ /** some styles **/ }; QScrollBar::sub