Ejemplo n.º 1
0
    def __init__(self):
        QtGui.QWidget.__init__(self)

        self.slider = QFloatSlider(QtCore.Qt.Horizontal)
        self.spinbox = QtGui.QDoubleSpinBox()

        # Fill background to avoid to see text or widget behind
        self.setAutoFillBackground(True)

        AbstractFloatWidget.__init__(self)

        # To be compatible with tree or table views, slider must keep focus
        self.slider.setFocusPolicy(QtCore.Qt.StrongFocus)
        self.setMinimumHeight(22)
        self.spinbox.setMinimumHeight(18)
        self.slider.setMinimumHeight(18)

        self.slider.floatValueChanged.connect(self.spinbox.setValue)
        self.spinbox.valueChanged.connect(self.slider.setFloatValue)
        # self.slider.floatValueChanged.connect(self.valueChanged)
        self.spinbox.valueChanged.connect(self.valueChanged)

        layout = QtGui.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        layout.addWidget(self.spinbox)
        layout.addWidget(self.slider)

        self.value_changed_signal = self.valueChanged