Struct qt_gui::QCloseEvent
source · #[repr(C)]pub struct QCloseEvent { /* private fields */ }
Expand description
The QCloseEvent class contains parameters that describe a close event.
C++ class: QCloseEvent
.
The QCloseEvent class contains parameters that describe a close event.
Close events are sent to widgets that the user wants to close, usually by choosing "Close" from the window menu, or by clicking the X title bar button. They are also sent when you call QWidget::close() to close a widget programmatically.
Close events contain a flag that indicates whether the receiver wants the widget to be closed or not. When a widget accepts the close event, it is hidden (and destroyed if it was created with the Qt::WA_DeleteOnClose flag). If it refuses to accept the close event nothing happens. (Under X11 it is possible that the window manager will forcibly close the window; but at the time of writing we are not aware of any window manager that does this.)
The event handler 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 handling, you should reimplement the event handler and ignore() the event.
The closeEvent() in the Application example shows a close event handler that asks whether to save a document before closing.
If you want the widget to be deleted when it is closed, create it with the Qt::WA_DeleteOnClose flag. This is very useful for independent top-level windows in a multi-window application.
QObjects emits the destroyed() signal when they are deleted.
If the last top-level window is closed, the QGuiApplication::lastWindowClosed() signal is emitted.
The isAccepted() function returns true
if the event's receiver has agreed to close the widget; call accept() to agree to close the widget and call ignore() if the receiver of this event does not want the widget to be closed.
Implementations§
source§impl QCloseEvent
impl QCloseEvent
sourcepub unsafe fn copy_from(
&self,
other: impl CastInto<Ref<QCloseEvent>>
) -> Ref<QCloseEvent>
pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QCloseEvent>> ) -> Ref<QCloseEvent>
The QCloseEvent class contains parameters that describe a close event.
Calls C++ function: QCloseEvent& QCloseEvent::operator=(const QCloseEvent& other)
.
The QCloseEvent class contains parameters that describe a close event.
Close events are sent to widgets that the user wants to close, usually by choosing "Close" from the window menu, or by clicking the X title bar button. They are also sent when you call QWidget::close() to close a widget programmatically.
Close events contain a flag that indicates whether the receiver wants the widget to be closed or not. When a widget accepts the close event, it is hidden (and destroyed if it was created with the Qt::WA_DeleteOnClose flag). If it refuses to accept the close event nothing happens. (Under X11 it is possible that the window manager will forcibly close the window; but at the time of writing we are not aware of any window manager that does this.)
The event handler 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 handling, you should reimplement the event handler and ignore() the event.
The closeEvent() in the Application example shows a close event handler that asks whether to save a document before closing.
If you want the widget to be deleted when it is closed, create it with the Qt::WA_DeleteOnClose flag. This is very useful for independent top-level windows in a multi-window application.
QObjects emits the destroyed() signal when they are deleted.
If the last top-level window is closed, the QGuiApplication::lastWindowClosed() signal is emitted.
The isAccepted() function returns true
if the event's receiver has agreed to close the widget; call accept() to agree to close the widget and call ignore() if the receiver of this event does not want the widget to be closed.
sourcepub unsafe fn new() -> CppBox<QCloseEvent>
pub unsafe fn new() -> CppBox<QCloseEvent>
Constructs a close event object.
Calls C++ function: [constructor] void QCloseEvent::QCloseEvent()
.
Constructs a close event object.
See also accept().
sourcepub unsafe fn new_copy(
other: impl CastInto<Ref<QCloseEvent>>
) -> CppBox<QCloseEvent>
pub unsafe fn new_copy( other: impl CastInto<Ref<QCloseEvent>> ) -> CppBox<QCloseEvent>
The QCloseEvent class contains parameters that describe a close event.
Calls C++ function: [constructor] void QCloseEvent::QCloseEvent(const QCloseEvent& other)
.
The QCloseEvent class contains parameters that describe a close event.
Close events are sent to widgets that the user wants to close, usually by choosing "Close" from the window menu, or by clicking the X title bar button. They are also sent when you call QWidget::close() to close a widget programmatically.
Close events contain a flag that indicates whether the receiver wants the widget to be closed or not. When a widget accepts the close event, it is hidden (and destroyed if it was created with the Qt::WA_DeleteOnClose flag). If it refuses to accept the close event nothing happens. (Under X11 it is possible that the window manager will forcibly close the window; but at the time of writing we are not aware of any window manager that does this.)
The event handler 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 handling, you should reimplement the event handler and ignore() the event.
The closeEvent() in the Application example shows a close event handler that asks whether to save a document before closing.
If you want the widget to be deleted when it is closed, create it with the Qt::WA_DeleteOnClose flag. This is very useful for independent top-level windows in a multi-window application.
QObjects emits the destroyed() signal when they are deleted.
If the last top-level window is closed, the QGuiApplication::lastWindowClosed() signal is emitted.
The isAccepted() function returns true
if the event's receiver has agreed to close the widget; call accept() to agree to close the widget and call ignore() if the receiver of this event does not want the widget to be closed.
Methods from Deref<Target = QEvent>§
sourcepub unsafe fn accept(&self)
pub unsafe fn accept(&self)
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Calls C++ function: void QEvent::accept()
.
Sets the accept flag of the event object, the equivalent of calling setAccepted(true).
Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget.
See also ignore().
sourcepub unsafe fn copy_from(&self, other: impl CastInto<Ref<QEvent>>) -> Ref<QEvent>
pub unsafe fn copy_from(&self, other: impl CastInto<Ref<QEvent>>) -> Ref<QEvent>
Calls C++ function: QEvent& QEvent::operator=(const QEvent& other)
.
sourcepub unsafe fn ignore(&self)
pub unsafe fn ignore(&self)
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Calls C++ function: void QEvent::ignore()
.
Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false).
Clearing the accept parameter indicates that the event receiver does not want the event. Unwanted events might be propagated to the parent widget.
See also accept().
sourcepub unsafe fn is_accepted(&self) -> bool
pub unsafe fn is_accepted(&self) -> bool
the accept flag of the event object
Calls C++ function: bool QEvent::isAccepted() const
.
the accept flag of the event object
Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget. By default, isAccepted() is set to true, but don't rely on this as subclasses may choose to clear it in their constructor.
For convenience, the accept flag can also be set with accept(), and cleared with ignore().
Access functions:
bool | isAccepted() const |
void | setAccepted(bool accepted) |
sourcepub unsafe fn set_accepted(&self, accepted: bool)
pub unsafe fn set_accepted(&self, accepted: bool)
the accept flag of the event object
Calls C++ function: void QEvent::setAccepted(bool accepted)
.
the accept flag of the event object
Setting the accept parameter indicates that the event receiver wants the event. Unwanted events might be propagated to the parent widget. By default, isAccepted() is set to true, but don't rely on this as subclasses may choose to clear it in their constructor.
For convenience, the accept flag can also be set with accept(), and cleared with ignore().
Access functions:
bool | isAccepted() const |
void | setAccepted(bool accepted) |
sourcepub unsafe fn spontaneous(&self) -> bool
pub unsafe fn spontaneous(&self) -> bool
Returns true
if the event originated outside the application (a system event); otherwise returns false
.
Calls C++ function: bool QEvent::spontaneous() const
.
Returns true
if the event originated outside the application (a system event); otherwise returns false
.
The return value of this function is not defined for paint events.
Trait Implementations§
source§impl CppDeletable for QCloseEvent
impl CppDeletable for QCloseEvent
source§impl Deref for QCloseEvent
impl Deref for QCloseEvent
source§impl DynamicCast<QCloseEvent> for QEvent
impl DynamicCast<QCloseEvent> for QEvent
source§unsafe fn dynamic_cast(ptr: Ptr<QEvent>) -> Ptr<QCloseEvent>
unsafe fn dynamic_cast(ptr: Ptr<QEvent>) -> Ptr<QCloseEvent>
Calls C++ function: QCloseEvent* dynamic_cast<QCloseEvent*>(QEvent* ptr)
.
source§impl StaticDowncast<QCloseEvent> for QEvent
impl StaticDowncast<QCloseEvent> for QEvent
source§unsafe fn static_downcast(ptr: Ptr<QEvent>) -> Ptr<QCloseEvent>
unsafe fn static_downcast(ptr: Ptr<QEvent>) -> Ptr<QCloseEvent>
Calls C++ function: QCloseEvent* static_cast<QCloseEvent*>(QEvent* ptr)
.
source§impl StaticUpcast<QEvent> for QCloseEvent
impl StaticUpcast<QEvent> for QCloseEvent
source§unsafe fn static_upcast(ptr: Ptr<QCloseEvent>) -> Ptr<QEvent>
unsafe fn static_upcast(ptr: Ptr<QCloseEvent>) -> Ptr<QEvent>
Calls C++ function: QEvent* static_cast<QEvent*>(QCloseEvent* ptr)
.