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.

666 questions
35
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,277
  • 2
  • 18
  • 34
23
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
  • 679
  • 6
  • 18
22
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
  • 18,687
  • 6
  • 49
  • 70
19
votes
3 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
  • 13,847
  • 39
  • 164
  • 305
18
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,267
  • 5
  • 25
  • 33
17
votes
4 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
  • 325
  • 1
  • 4
  • 10
16
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,203
  • 4
  • 24
  • 42
16
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
  • 314
  • 1
  • 3
  • 9
13
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,184
  • 18
  • 35
12
votes
4 answers

Qt: Styling QTabWidget

I'm using Qt and I have a QTabWidget setup in the Qt Designer Editor, you can see it in picture 1. As you can see after Tab4 there is an empty space all the way to the right edge, in someway I need to fill that space with a color, like in picture…
Martin
  • 1,625
  • 11
  • 33
  • 45
12
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
  • 123
  • 1
  • 4
12
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
  • 43,016
  • 36
  • 114
  • 168
11
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
  • 7,588
  • 27
  • 75
  • 120
11
votes
3 answers

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

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…
waterd
  • 492
  • 1
  • 5
  • 17
11
votes
1 answer

Is it possible to specify more than just "regular" and "bold" versions of a font in a Qt Stylesheet?

I have a font that has several font weights within one family (extra light, light, regular, semibold, bold, black). For this example, I'm using the free Google Webfont Source Sans Pro, but I've had the same issue with any font that has multiple…
ScottG
  • 723
  • 7
  • 17
1
2 3
44 45