Questions tagged [qtstylesheets]

For questions relating to Qt Style Sheets, which allow declarative customization of Qt objects.

Qt Style Sheets enable customization of the appearance of widgets, in addition to what is possible by subclassing QStyle. The concepts, terminology, and syntax of Qt Style Sheets are heavily inspired by HTML Cascading Style Sheets (CSS) but adapted to the world of widgets, and supporting features considered as valid for the CSS 2.1 specification only.

769 questions
39
votes
6 answers

Qt Stylesheet for custom widget

I have several custom widget in my current project. I wish to apply stylesheets to them and when I do so inside Qt Creator, it appears to work. However, when executing the program, no stylesheet is used. The stylesheets for the Qt widgets are…
jecjackal
  • 1,407
  • 2
  • 20
  • 35
28
votes
5 answers

How to change QPushButton text and background color

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…
alphanumeric
  • 17,967
  • 64
  • 244
  • 392
27
votes
2 answers

How to override just one property:value pair in Qt StyleSheet

I am writing newbie Qt5 code on OSX Mavericks and would like to override just one property:value pair of the StyleSheet for a given widget. If I run the following self-contained demonstration code: #include #include…
lcikgl
  • 759
  • 1
  • 8
  • 20
23
votes
1 answer

QSyntaxHighlighter - text selection overrides style

I'm making a custom code editor with QPlainTextEdit and QSyntaxHighlighter and I've encountered a glitch. I'd like to preserve syntax highlighting even within a selection. However, colors of the selection (environment colors) override the colors of…
LogicStuff
  • 19,397
  • 6
  • 54
  • 74
22
votes
6 answers

Using variables in qt StyleSheets

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…
SAM
  • 365
  • 1
  • 4
  • 10
21
votes
1 answer

Set QGroupBox title font size with style sheets

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…
Stephen
  • 3,515
  • 5
  • 27
  • 33
19
votes
1 answer

PyQt give color to a specific element

This might be an easy question, but I'm trying to give a color to a specific QLabel in my application and it doesn't work. The code I tried is the following : nom_plan_label =…
Johanna
  • 1,343
  • 4
  • 25
  • 44
19
votes
2 answers

How to apply style sheet to a custom widget in PyQt

# -*- 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) …
Anke_Pet
  • 354
  • 1
  • 3
  • 10
15
votes
3 answers

How to add style via setStyleSheet() without losing the original style(s) in Qt?

I know I can use setStyleSheet() to set styles in Qt. But when I use setStyleSheet() twice, the first styles are lost, which are set by first use of setStyleSheet(). For…
waterd
  • 603
  • 1
  • 7
  • 23
14
votes
4 answers

How to make a fast QTableView with HTML-formatted and clickable cells?

I'm making a dictionary program that displays word definitions in a 3-column QTableView subclass, as user types them, taking data from a QAbstractTableModel subclass. Something like that: I want to add various formatting to the text, I'm using…
Xilexio
  • 1,178
  • 19
  • 40
14
votes
1 answer

How to use Non-Standard Custom Font with Stylesheets?

I have a PyQt4 application that is being styled by an external .qss file by using the following code: ... app = QtGui.QApplication(sys.argv) stylesheet = open('mystylesheet.qss').read() app.setStyleSheet(stylesheet) ... Normally, I would specify…
Chris Aung
  • 9,152
  • 33
  • 82
  • 127
14
votes
3 answers

Get rid of Qt's dotted outline on QListView items

I'm trying to remove the dotted border on the text in this QListView::item using stylesheets: I've tried variations of border: 0 and show-decoration-selected: 0 on QListView, QListView::item and QListView::item::text to no effect. I'm using PyQt,…
Ross
  • 46,186
  • 39
  • 120
  • 173
13
votes
4 answers

Hide QScrollBar arrows

How to hide QScrollBar arrows? I need to hide in horizontal scrollbar. I was trying to hide with setStyleSheet: setStyleSheet(" QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal { height:0px; }" ) but it doesn't work.
programtg
  • 133
  • 1
  • 5
12
votes
2 answers

Removing the title from a QGroupBox

Is it possible to completely remove the title from a QGroupBox? If you just give it an empty title, the label where the title would be still takes up space. It looks like this: But I want it to look like this instead: I tried the following things…
Stefan Pfeifer
  • 593
  • 6
  • 16
12
votes
1 answer

Set background color of layout

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…
user-2147482637
  • 2,115
  • 8
  • 35
  • 56
1
2 3
51 52