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
6
votes
2 answers

How to change the background color of the QTableWidget's vertical header?

I would like to change the colors of a QTableWidget. I am almost getting the result I like, but two areas in the vertical header remain white: Before writing this post I actually managed to color also the upper left corner, but not the other area.…
JoeCool
  • 129
  • 7
6
votes
1 answer

How to animate a qpushbutton background's gradient to go from left to right on hover?

I'm practicing my programming skills and I am trying to build a login-system application with PyQt. I designed it after Login V4 . Now I'm trying to achieve that cool gradient animation from the Login button when you hover over it. But the CSS code…
Kirill
  • 303
  • 3
  • 18
6
votes
2 answers

Set background colour for a custom QWidget

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…
rmasp98
  • 97
  • 1
  • 6
6
votes
3 answers

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

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…
JasonGenX
  • 4,952
  • 27
  • 106
  • 198
6
votes
3 answers

How to set QTableWidget upper left corner using a background image?

How to set QTableWidget upper left corner using a background image? Now it is white. (Pointed in the image below) This is my style sheet code: QWidget { background-image: url(src/bg.jpg); color: #fffff8; } QHeaderView::section { …
liaokong
  • 145
  • 1
  • 9
6
votes
1 answer

QToolTip background-color is not clipped with border radius

I have styled my tooltips like this (not really that colors) QToolTip { border: 1px solid blue; border-radius: 10px; background-color: red; } But the background is not clipped at the corners: Why is it not clipped?
wutzebaer
  • 14,365
  • 19
  • 99
  • 170
6
votes
1 answer

QDockWidget float/close button hover images

Is there a way to change the hover/pressed icons for a QDockWidget(Qt 4.8) in a stylesheet? I'm using this style to change the button image for the default state: QDockWidget{ font-weight: bold; titlebar-close-icon:…
mfessenden
  • 598
  • 4
  • 12
6
votes
1 answer

Set QDockWidget border when docked and floating

I'm trying to style my QDockWidget so that it has a border when docked and when floating. I tried: QDockWidget { border: 5px solid purple; } But this only produced a border when floating. When docked, the border just disappeared. How can I…
John-Luke Laue
  • 3,736
  • 3
  • 32
  • 60
6
votes
1 answer

Modifying widget colour at runtime without overwriting stylesheet

My situation: I have a widget that has a stylesheet set. That stylesheet may or may not include colour settings. I want to change the colour of the widget, but I can't just do widget.setStyleSheet("QWidget {background-color: %s}"% colour), because…
ForeverWintr
  • 5,492
  • 2
  • 36
  • 65
6
votes
1 answer

QTabBar tab size doesn't scale with stylesheet font

I have the following stylesheet: QTabBar::tab { background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #2A2A2A, stop: 0.4 #E1E1E1, stop: 0.5 #E1E1E1, stop: 1.0 #2A2A2A); background-image:…
Nicolas Holthaus
  • 7,763
  • 4
  • 42
  • 97
6
votes
2 answers

QLabel margin and style sheet padding in labels in Qt

I have a label, and I set both padding in the style sheet and a margin using setMargin(). ui->label->setPixmap(redRectWithGreenBorder(80, 40)); ui->label->setStyleSheet("QLabel {border: 1px solid gray;border-radius: 2px;background-color:…
sashoalm
  • 75,001
  • 122
  • 434
  • 781
6
votes
1 answer

Customize QDial with stylesheet

There are comprehensive examples for style sheets of QWidgets here. Unfortunately QDial is missing from the examples. Can I change the appearance (basically the color, border of the rotary knob) just by a stylesheet? In this article a new dial class…
Horst Walter
  • 13,663
  • 32
  • 126
  • 228
6
votes
2 answers

Center the Text of QTextEdit horizontally and vertically

I want to center the text of my QTextEdit horizontally and vertically. I tried this, but it didn't work. m_myTextEdit = new QTextEdit("text edit", m_ui->centralWidget); m_myTextEdit->setGeometry(5, 50, 400,…
Niklas
  • 23,674
  • 33
  • 131
  • 170
6
votes
7 answers

How to change QPushButton icon/text spacing with stylesheets?

I'm fairly new to Qt's method of stylesheets and I am looking to adjust the spacing between the icon and text on a QPushButton. This is the gap I'm referring to: http://imageshack.us/scaled/thumb/593/4kem.png (stackoverflow won't let me post pics…
hannahd
  • 61
  • 1
  • 1
  • 5
6
votes
3 answers

Qt stylesheet, how to set color of QPalette::Link and QPlatte::LinkVisited

I use a library which uses colors of QPalette::Link and QPalette::LinkVisited as background and border color for a widget. I would like to change these colors with stylesheet. How can I set color of Link and LinkVisited with help of stylesheet? I…
Funt
  • 399
  • 8
  • 23