qtstylesheets

Qt Stylesheet syntax: targeting a specific button, not ALL buttons

泪湿孤枕 提交于 2020-07-08 14:00:27
问题 I have a window with two buttons. I'd like to decorate each one with a different stylesheet. They both have different object names, of course, but it seems that only the generic QPushButton stylesheet selector works. I tried: QPushButton#myBtnObjectName1 { /* style definitions */ } QPushButton#myBtnObjectName2 { /* style definitions */ } Tried the same with replacing the # with a . , or having the #myBtnObjetNameX only. Nothing works. Just: QPushButton { /* style definitions */ } Am I using a

Qt: change font weight

[亡魂溺海] 提交于 2020-07-06 12:59:12
问题 I would like to have my text in QLabel somewhere between bold and normal style and I believe that setting font-weight should be the answer to my problem. In Qt documentation, I have found out that there are two options how to change font-weight: From cpp side via: QFont::setWeight() method which accepts numbers 0-99 http://doc.qt.io/qt-4.8/qfont.html#Weight-enum From Qss style via: font-weight attribute, which accepts numbers 100,200,...,900 http://doc.qt.io/qt-4.8/stylesheet-reference.html

Updating QWidget style after setting it readonly

此生再无相见时 提交于 2020-01-30 05:24:48
问题 I have Qt style sheet ( qss ) for QLineEdit , using different styles for readonly and editable. Works fine, but if I toggle a QLineEdit to readonly (at runtime) the style does not change. Is there a way to force a stylesheet update of such a line edit? As requested, the stylesheet: QLineEdit { background: transparent; border: 1px solid green; border-radius: 5px; } QLineEdit[readOnly="true"] { background: rgba(40,40,40); border: 1px solid rgba(50,50,50); } 回答1: After change edit's state try

Change color of purple tab text in Konsole CSS

倖福魔咒の 提交于 2020-01-24 19:51:26
问题 When input comes in on a tab that is not active, the text for the tab changes to a purple color. What CSS selectors do I need to use to change this? I am using a custom stylesheet in Konsole to change how the tabs look, but can't figure out how to change this one value. This page makes no mention of it. I'm using Konsole 2.13.2(KDE 4.13.3) on Xubuntu 14.04(XFCE). 回答1: As of today, this tab-activity color appears to be set by void TabbedViewContainer::setTabActivity(int index , bool activity)

Set background colour for a custom QWidget

走远了吗. 提交于 2020-01-24 10:24:25
问题 I am attempting to create a custom QWidget (from PyQt5) whose background colour can change. However, all the standard methods of setting the background colour do not seem to work for a custom QWidget class So far I have attempted to change the colour through QSS stylesheet and by setting the palette. This works for a regular QWidget but for some reason not a custom widget. I have found reference custom QWidgets requiring a paintEvent() function in the C++ documentation https://wiki.qt.io/How

QGroupBox title vertical alignment

本小妞迷上赌 提交于 2020-01-23 18:00:29
问题 I have QGroupBox in my UI. The basic style is 2px width border, border radius and the title being vertically centered. I used the following style to my stylesheet (which is in a .qrc, applied in the main using app->setStylesheet): QGroupBox { border: 1px solid #22a4bc; border-radius: 0px; } QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top; /* position at the top center */ } The problem is, the title is now a few pixel down, and actually over the element IN the groupbox.

explicitly setting style sheet in python pyqt4?

好久不见. 提交于 2020-01-14 05:37:07
问题 In pyqt standard way for setting style sheet is like this: MainWindow.setStyleSheet(_fromUtf8("/*\n" "gridline-color: rgb(85, 170, 255);\n" "QToolTip\n" "{\n" " border: 1px solid #76797C;\n" " background-color: rgb(90, 102, 117);;\n" " color: white;\n" " padding: 5px;\n" " opacity: 200;\n" "}\n" "#label_3{\n" " background-color:rgb(90, 102, 117);\n" " color:white;\n" " padding-left:20px;\n" " \n" "}\n" "#label_2{\n" " color:white;\n" " padding-left:20px;\n" " \n" "}\n" But like we link the

QComboBox AbstractItemView::item

喜你入骨 提交于 2020-01-11 01:36:12
问题 Is there a way I could increase the height of the items, which are listed in a QComboBox control ? I tried following as suggested here in QTDevNet forums but with no luck QComboBox QAbstractItemView::item {margin-top: 3px;} I also tried this, still with no result. QComboBox QAbstractItemView::item {min-height: 20px;} Is it possible to achieve this at style-sheet level at all ? 回答1: Your style sheet seemed correct, so I tried it. It seems the problem is similar to this one on Qt centre:

changing stylesheet dynamically

醉酒当歌 提交于 2020-01-10 04:18:33
问题 I'm trying to change the style of my QLabel using a dynamic property since we can target this property in QSS like this: QLabel[foo = "warning"]{ color: red; } QLabel[foo = "success"]{ color: green; } the stye of my label does update when I use the QApplication::setStyleSheet() but does not seems to work when I change the value of the property. label = new QLabel( this ); label->setText( "some text" ); label->setProperty( "foo", "warning"); // after some event label->setProperty( "foo",

Apply different QSS stylesheet for custom QT class

旧时模样 提交于 2020-01-06 06:37:11
问题 I am using a qss stylesheet for my gui. It works well but I would like to define a different style sheet for my custom widget. By example, QPushbutton 's style works well but I would like to apply a different style for MyQPushButton (extends from QPushButton). I tried something like this : MyQPushButton { color: #dcdcdc; // some code here } QPushButton { color: #b1b1b1; // some code here } But QPushButton 's style has been applied on MyQPushButton . How to override this behavior ? 回答1: If you