您可以使用樣式表更改背景,但似乎是這樣。
自2014年1月6日您提出問題以來,情況可能已發生變化,但我能夠獲取樣式表,僅爲後臺工作。我嘗試過的其他東西都沒有效果。
請注意背景變化如何影響針。
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)
'QDial'不支持樣式表(在這裏是一個古老的bug報告https://bugreports.qt-project.org/browse/QTBUG-1160)。雖然它可以通過自定義的'QStyle'進行定製。用新的Fusion風格檢查'QDial'的外觀。 –