QCloseEvent(3qt)
β¨ QCloseEvent β the 3qt manual page, but make it make sense β¨
okay bestie, so this is the QCloseEvent page from the Qt 3.3.8 man pages (Trolltech era, we love a vintage moment π
). Sit down, grab a boba, and let's talk about close events.
πΈ NAME πΈ
QCloseEvent β the parameters that describe a close event, fr fr
π¦ SYNOPSIS π¦
#include <qevent.h>
Inherits QEvent. Yes queen, it's a whole event class π
Public Members
QCloseEvent ()
bool isAccepted () const
void accept ()
void ignore ()
π DESCRIPTION π
So the QCloseEvent class is literally just a lil container holding the parameters that describe a close event. That's it. That's the whole job. π
Close events get sent to widgets when the user wants to close them β usually by picking "Close" from the window menu, or by smashing that X titlebar button (you know the one). They also get sent when you call QWidget::close() to close a widget programmatically, because sometimes we do things ourselves.
A close event carries a flag that says whether the receiver actually wants the widget closed or not. Here's the tea: when a widget accepts the close event, it gets hidden (and destroyed too, if it was created with the WDestructiveClose flag). If it refuses to accept the close event, nothing happens. Literally nothing. (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. so like, theoretically rude, but nobody's doing it bestie.)
The application's main widget β QApplication::mainWidget() β is a special case, main character energy only. When it accepts the close event, Qt leaves the main event loop and the application is immediately terminated (i.e. it returns from the call to QApplication::exec() in the main() function). bye bye π
The event handler QWidget::closeEvent() is the one receiving close events. The default implementation of this event handler accepts the close event. So if you do NOT want your widget to be hidden, or you want some special handing, you should reimplement the event handler. slay, customise your life.
The closeEvent() in the Application Walkthrough shows a close event handler that asks whether to save a document before closing. iconic behaviour honestly, protect your files.
If you want the widget to be deleted when it is closed, create it with the WDestructiveClose widget flag. This is very useful for independent top-level windows in a multi-window application. chef's kiss π§
QObjects emits the destroyed() signal when they are deleted.
If the last top-level window is closed, the QApplication::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. simple as that π
See alsoQWidget::close(),QWidget::hide(),QObject::destroyed(),QApplication::setMainWidget(),QApplication::lastWindowClosed(),QApplication::exec(),QApplication::quit(), and Event Classes.
π MEMBER FUNCTION DOCUMENTATION π
QCloseEvent::QCloseEvent ()
Constructs a close event object with the accept parameter flag set to FALSE. starts off saying no, boundaries β
See also accept().
void QCloseEvent::accept ()
Sets the accept flag of the close event object.
Setting the accept flag indicates that the receiver of this event agrees to close the widget. yes, go ahead, close it.
The accept flag is not set by default.
If you choose to accept in QWidget::closeEvent(), the widget will be hidden. If the widget's WDestructiveClose flag is set, it will also be destroyed. π (in the good way)
See also ignore() and QWidget::hide().
Examples:
void QCloseEvent::ignore ()
Clears the accept flag of the close event object.
Clearing the accept flag indicates that the receiver of this event does not want the widget to be closed. hard pass, bestie π
The close event is constructed with the accept flag cleared.
See also accept().
Examples:
bool QCloseEvent::isAccepted () const
Returns TRUE if the receiver of the event has agreed to close the widget; otherwise returns FALSE. the vibe check function β¨
See also accept() and ignore().
π SEE ALSO π
π COPYRIGHT π
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.
β AUTHOR β
Generated automatically from the source code. (no human author to credit, the machine did it, and honestly? it ate.)
π BUGS π
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. (genuinely, good bug reports are a gift π«Ά)
The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. (we're the unofficial bestie version, iykyk)
If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qcloseevent.3qt) and the Qt version (3.3.8). thank uuu π
okay that's the whole page!! this little beauty is brought to you by Trolltech AS, dated 2 February 2007, and it ships as QCloseEvent(3qt) β so if you were born after this man page, no you weren't, and if you're reading it now, you're a real one. mwah πβ¨
π¦ where this page comes from
- fedora 43: qt3-devel-docs 3.3.8b-102.fc43 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- fedora 44: qt3-devel-docs 3.3.8b-103.fc44 Β· QPL-1.0 OR GPL-2.0-only OR GPL-3.0-only
- Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms