0
我有一個QWebView對象,並設置了WindowStaysOnTopHint,但是當我關閉它時,QWebView對象消失。取消設置WindowStaysOnTopHint使窗口消失
view = QWebView()
view.setWindowFlags(WindowStaysOnTopHint)
view.show()
....
#in some slot
view.setWindowFlags(WindowStaysBottomHint) # causes window to disappear
UPDATE
事先設置的是代碼的簡化版本,這裏有更多的細節。
class Window(QObject):
self.view = QWebView()
self.view.setWindowFlags(WindowStayOnTopHint)
self.installEventFilter(this)
....
def eventFilter(self,qobject, qevent):
if qevent.type() == QEvent.FocusOut:
# Turn on CloseButtonHint and turn off StayOnTopHint
self.view.setWindowFlags(Qt.WindowCloseButtonHint)
qobject.show() # previously I had self.view.show(), does not cause window to show
return super(FeedbackWindow, self).eventFilter(qobject, qevent)