qtstylesheets

Stylesheet for nested custom widget not applied

混江龙づ霸主 提交于 2019-12-23 22:14:57
问题 I expect the following code to show a small black area inside outer main window: class Canvas(QWidget): pass app = QApplication(sys.argv) outer = QWidget() w = Canvas(outer) w.setStyleSheet("background-color: black") outer.show() But looks like the stylesheet is not applied: entire outer window is gray. However, if w is a QWidget , code works as expected. When Canvas instance is shown directly (without parent) stylesheet is properly applied as well: w = Canvas() w.setStyleSheet("background

Qt QPushButton stylesheet hover

不打扰是莪最后的温柔 提交于 2019-12-23 19:28:32
问题 I have the following pushbutton stylesheet: QPushButton:hover{ background: qlineargradient(x1 : 0, y1 : 0, x2 : 0, y2 : 1, stop : 0.0 #ffd9aa, stop : 0.5 #ffbb6e, stop : 0.55 #feae42, stop : 1.0 #fedb74); } QPushButton { border: 1px solid #6593cf; border-radius: 2px; padding: 5px 15px 2px 5px; background: qlineargradient(x1 : 0, y1 : 0, x2 : 0, y2 : 1, stop : 0.0 #f5f9ff, stop : 0.5 #c7dfff, stop : 0.55 #afd2ff, stop : 1.0 #c0dbff); color: #006aff; font: bold large "Arial"; height: 30px; }

What does size “1em” in Qt qss mean, if there is no font size em?

拥有回忆 提交于 2019-12-23 14:48:15
问题 As of Qt 5 documentation says: The supported units are: px: pixels pt: the size of one point (i.e., 1/72 of an inch) em: the em width of the font (i.e., the width of 'M') ex: the ex width of the font (i.e., the height of 'x') However, Qt is limited to font sizes in pt and px and any other size must be in px, em or ex. When they say 1em is equivalent "M" , which M do they mean? Which font and pt size do they take to calculate that? Based on some other answers I can speculate it is some 12pt

Is it possible to change the color of a QSlider's handle according to its position?

北慕城南 提交于 2019-12-23 08:00:56
问题 I pretty well understood how to customize a QSlider through style sheets, but I am wondering if it is possible to do the following thing: I'd like the handle of the slider to go from blue to yellow. When set on the left, it's blue; and when you move it to the right, it will have a gradient from blue to yellow. If it is possible through the style sheets, how? And if not, how can I implement that in the paintEvent of a subclass of a QSlider? 回答1: Actually you don't really have to do anything

How can I get the background color returned by model take precedence over the style

守給你的承諾、 提交于 2019-12-23 05:41:18
问题 I have a QTreeView rendering QAbstractItemModel , where I would like to set the background of certain cells based on the data in the model. I return QBrush from model::data(Qt::BackgroundColorRole) and it works until I apply a style to an item. Setting any style to the item (even something that has nothing to do with background color, e.g. styling the border) overrides the color I return from the model (the calls to the model querying the background color are made). I.e. the view behaves as

[Qt]How to support :pressed state of style sheet for custom widget?

爱⌒轻易说出口 提交于 2019-12-22 12:37:43
问题 What i have :- I have a custom widget which extends QFrame (instead of QWidget as QFrame already has a working paintEvent implementation). I have overridden the mousePressed() and mouseReleased() to emit the pressed() released() and clicked() Signals. Everything upto this point is woring fine as expected. What i need :- This custom widget is having basic style sheet support and it supports the :hover state just fine. But the :pressed state is not working. I have already figured out that this

JPEG image not shown in Qt

你说的曾经没有我的故事 提交于 2019-12-22 10:55:36
问题 I set a background image(JPEG) on a Qt widget using setStyleSheet() . This is perfectly shown on my computer, but not on another computer. I am not getting a link error on the other computer -- the feature just doesn't work. Is there something I am missing in the distribution or build of my app, something that the Qt dev tools installs or is otherwise available, that isn't present on other machines? How can I distribute a Qt app that uses JPEG functionality? 回答1: JPEG support in Qt comes as a

Qt global style sheet loading?

匆匆过客 提交于 2019-12-21 09:32:22
问题 How can I load a style sheet (.qss style resource) globally with Qt? I am trying to make things a bit more efficient than: middleIntText -> setStyleSheet("QLineEdit { border: 1px solid gray; border-radius: 5px;padding: 0 8px; selection-background-color:darkgray; height:40px;font-size:15px;}"); I thought the following would work at loading QLineEdit the one time for all QLineEdit widgets: qss file: QLineEdit { border: 1px solid gray; border-radius: 5px; padding: 0 8px; selection-background

Qt Border, transparency, and padding. How to create this effect?

独自空忆成欢 提交于 2019-12-21 03:18:36
问题 I want to add a top right button for closing a widget that floats over others. I can´t make it float out of the contents of the panel. I tried several ways. Having the background normally doesn´t work. I cant make a widget float outside the box inside that background. It was done this way: border-style: solid; border-width: 12px 24px 37px 25px; border-image: url(:/resources/images/panel_border_corner_btn.png) 12 24 37 25 fill repeat; margin: 0px; padding: 0px; So i tried to make a background

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

江枫思渺然 提交于 2019-12-19 20:27:03
问题 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.