qtstylesheets

Using variables in qt StyleSheets

我们两清 提交于 2019-12-18 19:29:21
问题 Is there any possibility of giving variable name to hex/rgb numbers in .qss file . For eh myColor = #FFCC08 QPushButton { background-color: myColor;} So that i can define the variable at the top of the stylesheet and use the variable name whereever required instead of using the hex code. Also if i need to change the color then i have to change in one place and it will be reflected throught the file. I also searched for Saas but don't know how it can be used in qt. Thanks :) 回答1: You could

How to draw control with QStyle and with specified QSS?

不问归期 提交于 2019-12-18 09:42:44
问题 I'm trying to draw a checkbox in QStyledItemDelegate . I want checkbox to be drawng not with native look, but with style that specified with qApp->setStyleSheet() . I don't know why, but when I draw control with QStyle::drawPrimitive - it doesn't pick up global qss. Are there any solutions, how to manually draw check box with application style? Following code and screenshot demonstrate my problem: First check box is draw with QStyle::drawPrimitive , second check box is widget. #include

qt widen QScrollBar when hover using StyleSheet

徘徊边缘 提交于 2019-12-13 20:10:26
问题 I'm trying to change the width of a vertical QScrollBar with a custom stylesheet like QScrollBar:vertical { border: 2px solid grey; background: #32CC99; width: 10px; margin: 22px 0 22px 0;" } QScrollBar:vertical:hover { background: red; width: 25px ; } It doesn't work. Did I make any mistake? Can't we change the width of widget in run-time? 回答1: I don't think there is a way of doing this by using the stylesheets alone. You could create your own scrollbar and override the enterEvent and

clicked() signal for QWidget breaks stylesheets

£可爱£侵袭症+ 提交于 2019-12-13 19:38:12
问题 I want to connect clicked() signal of QWidget-container to my slot. So I wrote this code: hpp: class LinkWidget : public QWidget { Q_OBJECT public: explicit LinkWidget(QWidget * parent = 0 ); ~LinkWidget(); signals: void clicked(); protected: void mousePressEvent(QMouseEvent * event ) ; }; cpp: LinkWidget::LinkWidget(QWidget * parent) : QWidget(parent) { } LinkWidget::~LinkWidget() { } void LinkWidget::mousePressEvent(QMouseEvent * event) { emit clicked(); } Everything works fine, but I can't

QDockWidget change background color when floating

烂漫一生 提交于 2019-12-13 00:44:05
问题 I have a QDockWidget with a transparent background, but I would like to change the background color or background image when it is floating. It doesn't look like the qt style sheets have a pseudo state to tell you whether or not they are floating, so I'd like to know: is this possible to do? 回答1: Found the solution. Add the following connection in the code: connect(knobDock, &QDockWidget::topLevelChanged, [&] (bool isFloating) { if (isFloating) { setAttribute(Qt::WA_TranslucentBackground,

QCombobox down arrow image

前提是你 提交于 2019-12-12 12:21:37
问题 How to change Qcombobox down arrow image? Right now I'm using this QSS code, but this doesn't work, I can't remove down arrow border. QComboBox { border: 0px; } QComboBox::down-arrow { border: 0px; background-repeat: no-repeat; background-position: center center; background-image-width: 50px; border-image: url(./select-BG.png); heidth:50px; width:100px; } Here is the screenshot: 回答1: this is a pretty late answer but I think that I found the solution somewhere in the Qt-forums. When setting

Set QGroupBox title font size with style sheets

岁酱吖の 提交于 2019-12-12 08:18:47
问题 I would like to be able to set the font size of the title of a QGroupBox using style sheets. I can't seem to figure it out. Based on what I've read here, I've come up with the following code. Unfortunately, it doesn't quite work. groupbox->setStyleSheet(style) Where style is: QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top left; padding: 5 5px; font-size: 18px; font-weight: bold; } All of those style elements seem to be honored except font-size and font-weight .

Change StyleSheet of QToolBox in Qt

杀马特。学长 韩版系。学妹 提交于 2019-12-11 18:57:55
问题 I am designing a GUI in Qt . I have a MainWindow and a QToolBox in it. The class of my MainWindow is QTabWidget . According to the following pictures, I have a QToolBox with two tab named Encoder and Decoder . I could change the background color of each tab and its border . But I don't know how to change the color of background of each pane/tab . For example I want to change the color of Decoder pane to blue as follow. It is possible to put a frame-widget to page and change its background.

Not able to hide Choice-Indicator of the QComboBox

╄→гoц情女王★ 提交于 2019-12-11 10:24:18
问题 programmer When I set the background-color of the list view belonging to the QComboBox (per QSS), then this QComboBox will no more use the built-in-opticel-look-and feel. Instaed I have to specify all optical settings also per QSS-Stylesheet: QComboBox QListView { background-color:white; border:1px solid black; } The list view, which shows the chosable item, displays a checkbox on the left now. This box is checked for those item, chosen on last usage. How can i hide the column with the

How to set a custom widget's background color and border width?

老子叫甜甜 提交于 2019-12-11 06:37:16
问题 I have a custom widget whose parent is yet another custom widget. I am able to set the background color of the parent custom widget using QPalette and it works fine. But I am unable to set the child custom widget's border color using both QPalette and stylesheet . This is how I set my parent custom widget's background color: QPalette pal = parentCustomWidget->palette(); QColor color = {226, 208, 208}; pal.setColor (QPalette::Background, color); parentCustomWidget->setAutoFillBackground (true)