qtstylesheets

Qt stylesheet in derived class in C++ namespace (selector)

假装没事ソ 提交于 2019-11-30 21:00:29
I want to use my global qss stylesheet with a derived class. I understand I have to override the paintEvent ( style sheet reference , or here ). void CustomWidget::paintEvent(QPaintEvent *) { QStyleOption opt; opt.init(this); // tried initFrom too, same result=>not working QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); } However, it does not seem to work. With CDerived:QWidget and the following style sheet lines I face: CDerived { background-color: black; } // no effect QWidget { background-color: black; } // works CDerived implements paintEvent as above. Anything

QComboBox AbstractItemView::item

喜欢而已 提交于 2019-11-30 19:24:30
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 ? Your style sheet seemed correct, so I tried it. It seems the problem is similar to this one on Qt centre : QCompleter sets a custom QAbstractItemDelegate on it's model and unfortunately this custom item delegate does not

Flat QPushButton, background-color doesn't work

南楼画角 提交于 2019-11-30 14:10:50
I created QPushButton in Qt Designer with this stylesheet: QPushButton#pushButton { background-color: #ffffff; } QPushButton#pushButton:disabled { background-color: yellow; } QPushButton#pushButton:pressed { background-color: orange; } QPushButton#pushButton:focus:pressed { background-color: black; } QPushButton#pushButton:focus { background-color: green; } QPushButton#pushButton:hover { background-color: red; } QPushButton#pushButton:checked { background-color: pink; } It Works, but when i check "flat" in the properties, then it doesn't work anymore, I would like to ask you why? And how can i

QComboBox text colour won't change with style sheet

吃可爱长大的小学妹 提交于 2019-11-30 13:08:10
I'm trying to style a combobox in QT5. I'm using QT Creator for the layout and loading an app-wide style sheet at start up. The css I have related to my combobox is as follows: QComboBox { color:white; background-color: qlineargradient(x1:0, y1:0, x2:1,y2:1, stop: 1 rgba(228, 41, 81, 100), stop: 0 rgba(234, 107, 101, 100)); border-color: rgba(255,255,255,200); border-width: 1px; border-style: solid; } QComboBox QListView { border-style: none; background-color: qlineargradient(x1:0, y1:0, x2:1,y2:0, stop: 1 rgba(228, 41, 81, 100), stop: 0 rgba(234, 107, 101, 100)); } QComboBox::drop-down {

How to apply style sheet to a custom widget in PyQt

梦想与她 提交于 2019-11-30 11:41:54
问题 # -*- coding: utf-8 -*- import sys from PyQt4.QtGui import * from PyQt4.QtCore import * class MainWindow(QWidget): def __init__(self): super(MainWindow, self).__init__() self.setFixedWidth(200) self.setFixedHeight(200) stylesheet = \ ".QWidget {\n" \ + "border: 20px solid black;\n" \ + "border-radius: 4px;\n" \ + "background-color: rgb(255, 255, 255);\n" \ + "}" self.setStyleSheet(stylesheet) if __name__ == '__main__': app = QApplication(sys.argv) main = MainWindow() main.show() sys.exit(app

Qt TabWidget Each tab Title Background Color

谁说我不能喝 提交于 2019-11-30 09:38:47
问题 This is the original Tabwidget without setting title background color My customer ask me to do something like this; Set different background colour for title All - Yellow purchase - light blue POS Sales - light green Cash Sales - Pink invoice - light purple I have try the SetStyleSheet like: QTabBar { background-color : Yellow; } But all tab Color changed Somebody know how to setting each QTabBar background color? 回答1: These properties can not be set through QSS. To change the style to each

Qt stylesheet in derived class in C++ namespace (selector)

China☆狼群 提交于 2019-11-30 05:40:50
问题 I want to use my global qss stylesheet with a derived class. I understand I have to override the paintEvent (style sheet reference , or here). void CustomWidget::paintEvent(QPaintEvent *) { QStyleOption opt; opt.init(this); // tried initFrom too, same result=>not working QPainter p(this); style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); } However, it does not seem to work. With CDerived:QWidget and the following style sheet lines I face: CDerived { background-color: black; } // no

pyqt: How to apply style sheet to a custom widget

坚强是说给别人听的谎言 提交于 2019-11-30 04:02:51
# -*- coding: utf-8 -*- import sys from PyQt4.QtGui import * from PyQt4.QtCore import * class MainWindow(QWidget): def __init__(self): super(MainWindow, self).__init__() self.setFixedWidth(200) self.setFixedHeight(200) stylesheet = \ ".QWidget {\n" \ + "border: 20px solid black;\n" \ + "border-radius: 4px;\n" \ + "background-color: rgb(255, 255, 255);\n" \ + "}" self.setStyleSheet(stylesheet) if __name__ == '__main__': app = QApplication(sys.argv) main = MainWindow() main.show() sys.exit(app.exec_()) I want to add a border to a custom widget with style sheet, but the style sheet does not seem

How to change QPushButton text and background color

落花浮王杯 提交于 2019-11-30 00:47:24
问题 I am using following code to connect QMenu to QPushButton . When button is clicked a pull-down menu with multiple sub-menu's items is shown. button=QPushButton() button.setText("Press Me") font=QtGui.QFont() button.setFont(font) button.setSizePolicy(ToolButtonSizePolicy) button.setPopupMode(QtGui.QToolButton.InstantPopup) menu=QtGui.QMenu() button.setMenu(menu) menuItem1=menu.addAction('Menu Item1') menuItem2=menu.addAction('Menu Item2') Now depending on a condition I would like to customize

Flat QPushButton, background-color doesn't work

风格不统一 提交于 2019-11-29 19:48:19
问题 I created QPushButton in Qt Designer with this stylesheet: QPushButton#pushButton { background-color: #ffffff; } QPushButton#pushButton:disabled { background-color: yellow; } QPushButton#pushButton:pressed { background-color: orange; } QPushButton#pushButton:focus:pressed { background-color: black; } QPushButton#pushButton:focus { background-color: green; } QPushButton#pushButton:hover { background-color: red; } QPushButton#pushButton:checked { background-color: pink; } It Works, but when i