QCloseEvent 類

The QCloseEvent 類包含關閉事件描述參數。 更多...

頭: #include <QCloseEvent>
繼承: QEvent

公共函數

QCloseEvent ()

額外繼承成員

詳細描述

The QCloseEvent 類包含關閉事件描述參數。

關閉事件會被發送給用戶想要關閉的 Widget,通常是從窗口菜單選擇 Close,或點擊 X 標題欄按鈕。也會發送它們當調用 QWidget::close () 以編程方式關閉 Widget。

關閉事件包含指示接收者是否想要關閉 Widget 的標誌。當 Widget 接受關閉事件時,它被隱藏 (並被銷毀,若創建它是采用 Qt::WA_DeleteOnClose 標誌)。若它拒絕接受關閉事件,什麼都不發生 (在 X11,窗口管理器強製關閉窗口是可能的;但在編寫本文時,我們還不知道有任何窗口管理器可以做到這)。

事件處理程序 QWidget::closeEvent () receives close events. The default implementation of this event handler accepts the close event. If you do not want your widget to be hidden, or want some special handing, you should reimplement the event handler and ignore () 事件。

The 應用程序範例中的 closeEvent() 展示關閉事件處理程序,在關閉前詢問是否要保存文檔。

若想要刪除 Widget 當關閉它時,創建它采用 Qt::WA_DeleteOnClose 標誌。這對於在多窗口應用程序中的獨立頂層窗口非常有用。

QObject 發射 destroyed() 信號當刪除它們時。

若最後頂層窗口被關閉, QApplication::lastWindowClosed () 信號發射。

The isAccepted () function returns true if the event's receiver has agreed to close the widget; call accept () 以同意關閉 Widget 和調用 ignore () 若此事件的接收者不想要 Widget 被關閉。

另請參閱 QWidget::close (), QWidget::hide (), QObject::destroyed (), QCoreApplication::exec (), QCoreApplication::quit (),和 QApplication::lastWindowClosed ().

成員函數文檔編製

QCloseEvent:: QCloseEvent ()

構造關閉事件對象。

另請參閱 accept ().