まず最初に、私の目標を説明します。ブロッキング モードのユーザーに、進行中の作業があることを通知したいと思います。
QSplashScreen でクリック時の非表示を無効にすれば、これが私のニーズに合うことを願っています。C++ では、mousePressEvent メソッドで処理されます。
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()
私が間違っていることは何ですか?