QCloseEvent(3qt)

NAME
QCloseEvent - Parameters that describe a close event

SYNOPSIS

#include <qevent.h>

Inherits QEvent.

  Public Members
QCloseEvent ()
bool isAccepted () const
void accept ()
void ignore ()

DESCRIPTION
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. They are also sent when you call QWidget::close() to close a widget from inside the program.

Close 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.

The main widget of the application is a special case. When it accepts the close event, the application is immediately terminated.

The event handler QWidget::closeEvent() receives close events.

The default implementation of this event handler accepts the close event. This makes Qt hide the widget.

    void QWidget::closeEvent( QCloseEvent *e )
    {
        e->accept();                            // hides the widget
    }

If you do not want your widget to be hidden, you should reimplement the event handler.

    void MyWidget::closeEvent( QCloseEvent *e )
    {
        e->ignore();                            // does not hide the widget
    }

If you want your widget to be deleted when it is closed, simply delete it in the close event. In this case, calling QCloseEvent::accept() or QCloseEvent::ignore() makes no difference.

Warning: Be careful. The code below assumes that the widget was created on the heap using the new operator. Even when the widget has been created by new doing this is a tricky opreation. Be sure that you cannot have any other pointers to the widget hanging around.

    void MyWidget::closeEvent( QCloseEvent * )
    {
        delete this;
    }

QObject emits the destroyed() signal when it is deleted. This is a useful signal if a widget needs to know when another widget is deleted.

See also: QWidget::close(), QWidget::hide(), QObject::destroyed(), QApplication::setMainWidget() and QApplication::quit().

MEMBER FUNCTION DOCUMENTATION

QCloseEvent::QCloseEvent ()
Constructs a close event object with the accept parameter flag set to FALSE.

void QCloseEvent::accept ()
Sets the accep flag of the close event object.

Setting the accept flag indicates that the receiver of this event agrees to close the widget.

The accept flag is not set by default.

If you choose to accept in QWidget::closeEvent(), the widget will be hidden.

See also: ignore() and QWidget::hide().

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 hidden.

The accept flag is not set by default.

See also: accept().

bool QCloseEvent::isAccepted () const
Returns TRUE if the receiver of the event has agreed to close the widget.

See also: accept() and ignore().

SEE ALSO
http://www.troll.no/qt/qcloseevent.html

COPYRIGHT
Copyright 1992-1997 Troll Tech AS. See the LICENSE file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.