D
D
Danil Markov2015-11-11 21:32:11
Python
Danil Markov, 2015-11-11 21:32:11

How to make a signal for QSlider'a?

How to make the slider move to the clicked position on the QSlider. That is, we have a straight line and a slider that is located on it. When I click in a straight line, the slider moves, but by a certain distance. I think that I need to increase the PageStep to the value that I choose on the line, and then it should move to the desired distance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Danil Markov, 2015-11-13
@qmmp123

def mousePressEvent(self, event):
        print(Qt.Vertical)
        if event.button() == Qt.LeftButton:
            if self.orientation() == Qt.Vertical:
                self.setValue(self.minimum() + ((self.maximum() - self.minimum()) * (self.height() - event.y())) / self.height() )
            else:
                self.setValue(self.minimum() + ((self.maximum() - self.minimum()) * event.x()) / self.width())
            event.accept()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question