所有拳头我将描述我的目标:我想通知用户在阻塞模式下有一些工作正在进行中。QSplashScreen点击关闭
我希望如果我禁用点击QSplashScreen隐藏,这将符合我的需求。 在C++中,它在mousePressEvent Method的处理:
void QSplashScreen::mousePressEvent(QMouseEvent *)
{
hide();
}
,所以我希望,只是重写此方法会剿隐藏,但我的代码无法正常工作:
from PyQt4 import QtGui, QtCore
import sys
import time
class MySplash(QtGui.QSplashScreen):
def __init__(self):
super(MySplash, self).__init__()
self.setPixmap(QtGui.QPixmap("betting.gif"))
def mousePressEvent(self, mouse_event):
print('mousePressEvent', mouse_event)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
splash = MySplash()
splash.show()
QtGui.qApp.processEvents()
print('Here I am')
splash.showMessage('Here I am')
time.sleep(2)
print('Do some work')
time.sleep(2)
splash.close()
我在做什么错?
如果您继承了'QSplashScreen',则不会在您的子类中阻止您重写/重新实现它。该成员函数在'QSplashScreen'中声明为虚拟保护,即它被设计为被子类覆盖。 – 2013-07-02 10:48:18