이 페이지에서

QCloseEvent Class

QCloseEvent 클래스에는 닫기 이벤트를 설명하는 매개변수들이 포함되어 있습니다. 더 보기...

헤더: #include <QCloseEvent>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
상속: QEvent

공개 함수

보호된 함수

QCloseEvent(QCloseEvent &&)
QCloseEvent &operator=(QCloseEvent &&)
QCloseEvent &operator=(const QCloseEvent &other)

상세 설명

닫기 이벤트는 사용자가 닫기를 원하는 위젯으로 전송되며, 일반적으로 창 메뉴에서 "닫기"를 선택하거나 X 의 제목 표시줄 버튼을 클릭하여 발생합니다. 또한 QWidget::close()를 호출하여 프로그래밍 방식으로 위젯을 닫을 때도 전송됩니다.

닫기 이벤트에는 수신자가 위젯을 닫을지 여부를 나타내는 플래그가 포함되어 있습니다. 위젯이 닫기 이벤트를 수락하면, 위젯은 숨겨집니다( Qt::WA_DeleteOnClose 플래그로 생성된 경우 소멸됩니다). 닫기 이벤트 수락을 거부하면 아무 일도 일어나지 않습니다. (X11 환경에서는 윈도우 관리자가 창을 강제로 닫을 수도 있지만, 이 문서를 작성하는 시점에서는 이를 수행하는 윈도우 관리자는 알려진 바가 없습니다.)

이벤트 핸들러 ` QWidget::closeEvent()`는 닫기 이벤트를 수신합니다. 이 이벤트 핸들러의 기본 구현은 닫기 이벤트를 수락합니다. 위젯이 숨겨지는 것을 원치 않거나 특별한 처리가 필요한 경우, 이벤트 핸들러를 재구현하고 ` ignore()`를 호출하여 이벤트를 거부해야 합니다.

위젯이 닫힐 때 삭제되도록 하려면 Qt::WA_DeleteOnClose 플래그를 사용하여 위젯을 생성하십시오. 이는 다중 창 애플리케이션에서 독립적인 최상위 창을 다룰 때 매우 유용합니다.

QObjects는 삭제될 때 destroyed() 신호를 발생시킵니다.

마지막 최상위 창이 닫히면 QGuiApplication::lastWindowClosed() 신호가 발생합니다.

isAccepted() 함수는 이벤트의 수신자가 위젯을 닫는 데 동의한 경우 true 를 반환합니다. 위젯을 닫는 데 동의하려면 accept()를 호출하고, 이 이벤트의 수신자가 위젯이 닫히는 것을 원하지 않는 경우 ignore()를 호출하십시오.

QWidget::close(), QWidget::hide(), QObject::destroyed(), QCoreApplication::exec(), QCoreApplication::quit(), QGuiApplication::lastWindowClosed()도 참조하십시오 .

멤버 함수 문서

QCloseEvent::QCloseEvent()

close 이벤트 객체를 생성합니다.

accept()도 참조하십시오 .

[protected delete] QCloseEvent::QCloseEvent(QCloseEvent &&)

QCloseEvent 의 인스턴스를 move-construct로 생성합니다. 이 함수는 삭제되었습니다.

[protected delete] QCloseEvent &QCloseEvent::operator=(QCloseEvent &&)

other 를 이 QCloseEvent 인스턴스에 이동-할당합니다. 이 함수는 삭제됩니다.

[noexcept protected default] QCloseEvent &QCloseEvent::operator=(const QCloseEvent &other)

other 을 이 QCloseEvent 인스턴스에 복사-할당합니다.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.