所有拳頭我將描述我的目標:我想通知用戶在阻塞模式下有一些工作正在進行中。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