本文整理匯總了Python中PyQt5.Qt.QDoubleSpinBox.maximum方法的典型用法代碼示例。如果您正苦於以下問題:Python QDoubleSpinBox.maximum方法的具體用法?Python QDoubleSpinBox.maximum怎麽用?Python QDoubleSpinBox.maximum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PyQt5.Qt.QDoubleSpinBox
的用法示例。
在下文中一共展示了QDoubleSpinBox.maximum方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: SliderWidget
# 需要導入模塊: from PyQt5.Qt import QDoubleSpinBox [as 別名]
# 或者: from PyQt5.Qt.QDoubleSpinBox import maximum [as 別名]
class SliderWidget(QDialog):
'''
class SliderWidget
'''
valueChanged = QtCore.pyqtSignal(float)
def __init__(self, title, parent = None):
super(SliderWidget, self).__init__(parent, Qt.FramelessWindowHint)
self._mousePressed = False
self._orgPos = QPoint(0, 0)
self.setObjectName('SliderWidget')
self.resize(500, 150)
#
self.stylize()
# main layout
labelTitle = QLabel(title, self)
buttonClose = JCloseButton(self)
buttonClose.setObjectName('buttonClose')
buttonClose.setToolTip('關閉')
horiLayoutTitle = QHBoxLayout()
horiLayoutTitle.setContentsMargins(6, 0, 6, 6)
horiLayoutTitle.addWidget(labelTitle, 0, Qt.AlignTop)
horiLayoutTitle.addStretch()
horiLayoutTitle.addWidget(buttonClose, 0, Qt.AlignTop)
self.doubleSpinBox = QDoubleSpinBox(self)
self.doubleSpinBox.setObjectName('doubleSpinBox')
self.doubleSpinBox.setMinimumWidth(200)
self.doubleSpinBox.setRange(0, 6000)
self.doubleSpinBox.setDecimals(2)
self.doubleSpinBox.setSingleStep(0.01)
self.slider = QSlider(Qt.Horizontal, self)
self.slider.setObjectName('slider')
self.slider.setRange(self.doubleSpinBox.minimum(),
self.doubleSpinBox.maximum())
vertLayoutMain = QVBoxLayout(self)
vertLayoutMain.addLayout(horiLayoutTitle)
vertLayoutMain.addWidget(self.doubleSpinBox, 0, Qt.AlignHCenter)
vertLayoutMain.addSpacing(5)
vertLayoutMain.addWidget(self.slider)
self.slider.rangeChanged.connect(self.doubleSpinBox.setRange)
self.doubleSpinBox.valueChanged.connect(self.doubleSpinBoxValueChanged)
self.slider.valueChanged.connect(self.setValue)
buttonClose.clicked.connect(self.close)
def setRange(self, minValue, maxValue):
self.slider.setRange(minValue, maxValue)
def setDecimals(self, prec):
self.doubleSpinBox.setDecimals(prec)
def setSingleStep(self, value):
self.doubleSpinBox.setSingleStep(value)
def setPrefix(self, prefix):
self.doubleSpinBox.setPrefix(prefix)
def setSuffix(self, suffix):
self.doubleSpinBox.setSuffix(suffix)
def doubleSpinBoxValueChanged(self, value):
self.slider.setValue(value)
self.valueChanged.emit(value)
@QtCore.pyqtSlot(float)
def setValue(self, value):
self.doubleSpinBox.setValue(value)
@QtCore.pyqtSlot()
def stylize(self):
styles.stylize(self)
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
self._mousePressed = True
self._orgPos = event.pos()
self.setCursor(Qt.ClosedHandCursor)
def mouseMoveEvent(self, event):
if self._mousePressed:
curPos = event.pos()
curGeom = self.geometry()
self.move(curGeom.topLeft() + curPos - self._orgPos)
def mouseReleaseEvent(self, event):
self._mousePressed = False
self.setCursor(Qt.ArrowCursor)