本文整理汇总了Python中PyQt4.QtCore.QTime.isNull方法的典型用法代码示例。如果您正苦于以下问题:Python QTime.isNull方法的具体用法?Python QTime.isNull怎么用?Python QTime.isNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QTime
的用法示例。
在下文中一共展示了QTime.isNull方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AutoSaver
# 需要导入模块: from PyQt4.QtCore import QTime [as 别名]
# 或者: from PyQt4.QtCore.QTime import isNull [as 别名]
class AutoSaver(QObject):
"""
Class implementing the auto saver.
"""
AUTOSAVE_IN = 1000 * 3
MAXWAIT = 1000 * 15
def __init__(self, parent, save):
"""
Constructor
@param parent reference to the parent object (QObject)
@param save slot to be called to perform the save operation
"""
QObject.__init__(self, parent)
if parent is None:
raise RuntimeError("AutoSaver: parent must not be None.")
self.__save = save
self.__timer = QBasicTimer()
self.__firstChange = QTime()
def changeOccurred(self):
"""
Public slot handling a change.
"""
if self.__firstChange.isNull():
self.__firstChange.start()
if self.__firstChange.elapsed() > self.MAXWAIT:
self.saveIfNeccessary()
else:
self.__timer.start(self.AUTOSAVE_IN, self)
def timerEvent(self, evt):
"""
Protected method handling timer events.
@param evt reference to the timer event (QTimerEvent)
"""
if evt.timerId() == self.__timer.timerId():
self.saveIfNeccessary()
else:
QObject.timerEvent(self, evt)
def saveIfNeccessary(self):
"""
Public method to activate the save operation.
"""
if not self.__timer.isActive():
return
self.__timer.stop()
self.__firstChange = QTime()
self.__save()