示例代码
代码语言:python
代码运行次数:0
复制from PySide6.QtWidgets import QApplication, QDial, QMainWindow
def dial_mouse_changed(value: int):
print('dial text changed:', value)
class MyDial(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle('Analogue Dial')
self.dial = QDial()
self.dial.setRange(-100, 100)
self.dial.setSingleStep(1)
self.dial.sliderMoved.connect(dial_mouse_changed)
self.dial.sliderReleased.connect(self.dial_released)
self.dial.sliderPressed.connect(self.dial_pressed)
self.setCentralWidget(self.dial)
def dial_pressed(self):
print('dial pressed:', self.dial.sliderPosition())
def dial_released(self):
print('dial released:', self.dial.sliderPosition())
if __name__ == '__main__':
app = QApplication()
ins = MyDial()
ins.show()
app.exec()
运行效果