PyQt / Five minute steps in a Q Time Edit

Legacy Wiki Page

This page was migrated from the old MoinMoin-based wiki. Information may be outdated or no longer applicable. For current documentation, see python.org.

Five minute steps in a QTimeEdit

On the #pyqt channel on Freenode, rowinggolfer asked if it was possible to make QTimeEdit step in five minute intervals.

The following subclass reimplements the stepBy() method and calls the base class implementation with an adjusted number of steps.

   1 class FiveMinuteTimeEdit(QTimeEdit):
   2   def stepBy(self, steps):
   3     if self.currentSection() == self.MinuteSection:
   4       QTimeEdit.stepBy(self, steps * 5)
   5     else:
   6       QTimeEdit.stepBy(self, steps)