我有一个 QWebView 对象,我设置了WindowStaysOnTopHint,但是当我关闭它时, QWebView 对象消失了。
view = QWebView()
view.setWindowFlags(WindowStaysOnTopHint)
view.show()
....
#in some slot
view.setWindowFlags(WindowStaysBottomHint) # causes window to disappear
更新
之前的设置是代码的简化版本,这里有更多详细信息。
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)