2013-11-02 145 views
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) 

回答

2

從文檔的setWindowFlags

注:該函數調用的setParent()改變標誌,當一個 窗口,導致窗口小部件被隱藏。你必須調用show()來使 小部件再次可見。