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 is supporting style sheets, but can it not be done with Qt's standard class?
The slider / scrollbar examples show how every detail can be tweaked, so I wonder if there is something similar for QDial
? I understand I can exchange the underlying image, but would prefer an easy way just to set its color, border.
I have tried the standard attributes such as backgroud-color
, background
, color
with no success. Also tried QDial::handle
, so a hint would be useful.
You can change the background with style sheets but that appears to be it.
Perhaps things have changed since you asked the question on Jan 6, 2014 but I was able to get style sheets to work for the background only. Everything else I tried had no effect.
Notice how the background change affects the needle too.
from PyQt4 import QtGui, QtCore
import os
import time
class MyDial(QtGui.QDial):
style ='''
QDial
{
background-color:QLinearGradient(
x1: 0.177, y1: 0.004, x2: 0.831, y2: 0.911,
stop: 0 white,
stop: 0.061 white,
stop: 0.066 lightgray,
stop: 0.5 #242424,
stop: 0.505 #000000,
stop: 0.827 #040404,
stop: 0.966 #292929,
stop: 0.983 #2e2e2e
);
}
'''
def __init__(self, parent=None):
super(MyDial, self).__init__(parent)
self.setStyleSheet(self.style)
self.setRange(0,100)
self.setValue(0)
self.setWrapping(True) # Smooth transition from 99 to 0
self.setNotchesVisible(True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With