qtstylesheets

How to set QTableWidget upper left corner using a background image?

六月ゝ 毕业季﹏ 提交于 2019-12-02 01:52:36
How to set QTableWidget upper left corner using a background image? Now it is white. (Pointed in the image below) This is my style sheet code: QWidget { background-image: url(src/bg.jpg); color: #fffff8; } QHeaderView::section { background-image: url(src/bg.jpg); padding: 4px; border: 1px solid #fffff8; } QTableWidget { gridline-color: #fffff8; } QTableWidget QTableCornerButton::section { background-image: url(src/bg.jpg); border: 1px solid #fffff8; } You will have to use a custom row-headers column: disable the builtin row headers column, add a column to hold row numbers, define slots to

How to get font of widget in Qt set by stylesheet?

余生颓废 提交于 2019-12-01 20:55:43
问题 I have Qt application with custom stylesheet applied to it (and for all widgets in general) with custom font included in this stylesheet. But when try to get font of some widget font() method return different font. I want to get the font of a QWidget which is set by a stylesheet. The font() method always returns the global system font or the font set by setFont() , but not the font which is set by setStyleSheet() and is used for painting in the widget. I need the font to do some calculations

Qt stylesheet weird line on top of tab bar

ぐ巨炮叔叔 提交于 2019-12-01 20:35:36
I style my QTabWidget and got a weird line on top of the tab bar. It only happens when it has multi tabs. QTabWidget::pane { border-top: 1px solid #c4c4c4; top: -1px; } QTabWidget::tab-bar { left: 5px; } Any advice to fix this? Thanks. You need to turn off the base in the QTabBar : QTabBar { qproperty-drawBase: 0; } 来源: https://stackoverflow.com/questions/33940257/qt-stylesheet-weird-line-on-top-of-tab-bar

How to get font of widget in Qt set by stylesheet?

折月煮酒 提交于 2019-12-01 18:58:28
I have Qt application with custom stylesheet applied to it (and for all widgets in general) with custom font included in this stylesheet. But when try to get font of some widget font() method return different font. I want to get the font of a QWidget which is set by a stylesheet. The font() method always returns the global system font or the font set by setFont() , but not the font which is set by setStyleSheet() and is used for painting in the widget. I need the font to do some calculations based on the font size. I use Qt 4.6. How can I get real font of widget (that is showing when

Set background color of layout

六眼飞鱼酱① 提交于 2019-12-01 18:20:11
As the layout object has no attribute ".setStyleSheet()", how can one set the background color for a given layout? As a visual explanation, I can set both the label and the button background color, but not the entire layout, which includes the spacer. Programatically, I'm organizing some information in horizontal layouts and displaying them in a frame. I would like to alternate background colors for each loop. for param_name in parameters: hlayouts.append(QtGui.QHBoxLayout()) labels.append(QtGui.QLabel("%s"%param_name)) sliders.append(QtGui.QSpacerItem(10,10,hPolicy=QtGui.QSizePolicy.Expanding

How to add style via setStyleSheet() without losing orignal style in Qt?

試著忘記壹切 提交于 2019-12-01 17:45:46
I Konw I can use setStyleSheet() to set style in Qt.But I encountered a problem,when I used setStyleSheet() twice first styles lost,which are set by first use of setStyleSheet() . For exmaple , setStyleSheet("QLabel{color:red;}"); ………… setStyleSheet("QLabel{border-image:url(……)}") When I set border-image,the red color property lost. I tried to solve it by using setStyleSheet(styleSheet()+QString("QLabel{border-image:url(……)}")); but it was the same that only the border-image property existed. Must I add every style property when I use setStyleSheet(),although that I set it before. Thanks for

Set background color of layout

China☆狼群 提交于 2019-12-01 17:16:48
问题 As the layout object has no attribute ".setStyleSheet()", how can one set the background color for a given layout? As a visual explanation, I can set both the label and the button background color, but not the entire layout, which includes the spacer. Programatically, I'm organizing some information in horizontal layouts and displaying them in a frame. I would like to alternate background colors for each loop. for param_name in parameters: hlayouts.append(QtGui.QHBoxLayout()) labels.append

Determining Qt stylesheet options programmatically?

99封情书 提交于 2019-12-01 17:01:27
Is it possible to look up stylesheet values at runtime in Qt? I'm working on a custom button derived from QPushButton that has some stylesheet properties set. I'd like to be able to look up some stylesheet settings like border width, margin , padding-top , padding-left , padding-right , etc. Is this at all possible to do without calling widget->getStyleSheet() and parsing out the values myself? Don't think so, you might be able to find something by stepping through the drawing code. But the parsing and the application of stylesheets is pretty optimised and uses a lot of preprocessing. I don't

Dynamically change font size of QLabel to fit available space

为君一笑 提交于 2019-12-01 11:14:07
I'm trying to make an horizontal layout with 3 QLabel scale use all its available space. More specifically, this is what I have this is what I am aiming for At the moment, the second image is achieved by changing the stylesheet of the qlabels with a slider. Additionally, since I have the the three labels in a layout inside a groupbox, the groupbox resizes to fit its contents, cool. Now I wanted to drop the slider approach and instead autofit the space available when moving the splitters. In this question, OP reimplements the resizeEvent , and I've seen other posts suggesting the same, changing

Dynamically change font size of QLabel to fit available space

血红的双手。 提交于 2019-12-01 08:45:52
问题 I'm trying to make an horizontal layout with 3 QLabel scale use all its available space. More specifically, this is what I have this is what I am aiming for At the moment, the second image is achieved by changing the stylesheet of the qlabels with a slider. Additionally, since I have the the three labels in a layout inside a groupbox, the groupbox resizes to fit its contents, cool. Now I wanted to drop the slider approach and instead autofit the space available when moving the splitters. In