📄 qcloseevent.3qt
字号:
.TH QCloseEvent 3qt "6 July 1999" "Troll Tech AS" \" -*- nroff -*-.\" Copyright 1992-1999 Troll Tech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQCloseEvent \- Parameters that describe a close event.SH SYNOPSIS.br.PP\fC#include <qevent.h>\fR.PPInherits QEvent..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQCloseEvent\fR ()".br.ti -1c.BI "bool \fBisAccepted\fR () const".br.ti -1c.BI "void \fBaccept\fR ()".br.ti -1c.BI "void \fBignore\fR ()".br.in -1c.SH DESCRIPTIONThe QCloseEvent class contains parameters that describe a close event..PPClose events are sent to widgets that the user wants to close, usually by choosing "Close" from the window menu. They are also sent when you call QWidget::close() to close a widget from inside the program..PPClose events contain a special accept flag which tells whether the receiver wants the widget to be closed. When a widget accepts the close event, it is hidden. If it refuses to accept the close event, nothing happens..PPThe main widget of the application is a special case. When it accepts the close event, the application is immediately terminated..PPThe event handler QWidget::closeEvent() receives close events..PPThe default implementation of this event handler accepts the close event. This makes Qt hide the widget..PP.nf.br void QWidget::closeEvent( QCloseEvent *e ).br {.br e->accept(); // hides the widget.br }.fi.PPIf you do not want your widget to be hidden, you should reimplement the event handler..PP.nf.br void MyWidget::closeEvent( QCloseEvent *e ).br {.br e->ignore(); // does not hide the widget.br }.fi.PPA typical reimplementation of a close event handler is shown in the qwerty/qwerty.cpp example: If the document wasn't changed, the close event is accepted with \fIe->except().\fR If there are unsaved changes, it asks the user whether she wants to save the data. This is done with QMessageBox::warning(). The close event is only accepted if the data was either saved successfully or if the user explicitely stated that the modifications shall be discarded..PPIf you want your widget also to be deleted when it is closed, simply create it with the \fCWDestructiveClose\fR widget flag. This is very useful for the independent toplevel windows of a multi window application. The qwerty/qwerty.cpp example also makes use of this..PP\fBWarning:\fR Be careful. destructive close implies that the widget was created on the heap using the \fCnew\fR operator. Even when the widget has been created by new doing this is a tricky operation. Be sure that you cannot have any other pointers to the widget hanging around..PPQObject emits the destroyed() signal when it is deleted. This is a useful signal if a widget needs to know when another widget is deleted..PPIf the last toplevel window is closed, the QApplication::lastWindowClosed() signal is emitted..PPSee also: QWidget::close(), QWidget::hide(), QObject::destroyed(), QApplication::setMainWidget(), QApplication::lastWindowClosed() and QApplication::quit()..PPExamples:.(lpopup/popup.cpp.)l.SH MEMBER FUNCTION DOCUMENTATION.SH "QCloseEvent::QCloseEvent ()"Constructs a close event object with the accept parameter flag set to FALSE..SH "void QCloseEvent::accept ()"Sets the accept flag of the close event object..PPSetting the accept flag indicates that the receiver of this event agrees to close the widget..PPThe accept flag is not set by default..PPIf you choose to accept in QWidget::closeEvent(), the widget will be hidden. If the widget was created with the WDestructiveClose widget flag, it is also destroyed..PPSee also: ignore() and QWidget::hide()..PPExamples:.(lpopup/popup.cpp.)l.SH "void QCloseEvent::ignore ()"Clears the accept flag of the close event object..PPClearing the accept flag indicates that the receiver of this event does not want the widget to be closed..PPThe accept flag is not set by default..PPSee also: accept()..SH "bool QCloseEvent::isAccepted () const"Returns TRUE if the receiver of the event has agreed to close the widget..PPSee also: accept() and ignore()..SH "SEE ALSO".BR http://www.troll.no/qt/qcloseevent.html.SH COPYRIGHTCopyright 1992-1999 Troll Tech AS. See the license file included inthe distribution for a complete license statement..SH AUTHORGenerated automatically from the source code.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -