[PyQt] PyQt4 : connecting QTimeEdit to QScrollBar ?
    Vincent Vande Vyvre 
    vincent.vandevyvre at swing.be
       
    Sun Nov 18 08:24:09 GMT 2012
    
    
  
Le 18/11/12 00:27, Cruella Deville a écrit :
> Hi can somebody please help me?
> I am trying to control the hours, minutes and seconds of a QTimeEdit
> independently by using 3 QScrollBars.
> Here's what I've got so far. It works but the setTime command always
> resets the elements that I don't want to affect. Is there something
> like setMinutes, setHours or setSeconds ?
> I've also thought about using a QLCDNumber widget instead of the
> QTimeEdit but I'm not sure if that would work.
> Thanks for any help.
>
> ...
>
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
You need to reset all the three values in timeEdit.
This works:
from PyQt4 import QtCore, QtGui
class Help(QtGui.QMainWindow):
    def __init__(self):
        super(Help, self).__init__()
        #QTimeEdit
        self.TimeEdit = QtGui.QTimeEdit()
        self.TimeEdit.setDisplayFormat("hh:mm:ss")
        self.time = QtCore.QTime()
        self.hour = 0
        self.min = 0
        self.sec = 0
        #Hours ScrollBar
        ...
        ...
    def HourChanged(self):
        self.hour = self.HourScrollBar.value()
        self.set_time()
    def MinChanged(self):
        self.min = self.MinScrollBar.value()
        self.set_time()
    def SecChanged(self):
        self.sec = self.SecScrollBar.value()
        self.set_time()
    def set_time(self):
        self.time.setHMS(self.hour, self.min, self.sec)
        self.TimeEdit.setTime(self.time)
...
-- 
Vincent V.V.
Oqapy <https://launchpad.net/oqapy> . Qarte
<https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager>
    
    
More information about the PyQt
mailing list