Doc: Mention that calling parent class event() is important
If you don't deleteLater and more won't work Change-Id: I47cbb24f8e22a7f269a0297410e4163878819f82 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
867fc30c7c
commit
0396c7a7d8
@ -486,6 +486,33 @@ QObject::connect(socket, &QTcpSocket::connected, this, [=] () {
|
|||||||
}, Qt::AutoConnection);
|
}, Qt::AutoConnection);
|
||||||
//! [51]
|
//! [51]
|
||||||
|
|
||||||
|
//! [52]
|
||||||
|
class MyClass : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MyClass(QWidget *parent = 0);
|
||||||
|
~MyClass();
|
||||||
|
|
||||||
|
bool event(QEvent* ev)
|
||||||
|
{
|
||||||
|
if (ev->type() == QEvent::PolishRequest) {
|
||||||
|
// overwrite handling of PolishRequest if any
|
||||||
|
doThings();
|
||||||
|
return true;
|
||||||
|
} else if (ev->type() == QEvent::Show) {
|
||||||
|
// complement handling of Show if any
|
||||||
|
doThings2();
|
||||||
|
QWidget::event(ev);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// Make sure the rest of events are handled
|
||||||
|
return QWidget::event(ev);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
//! [52]
|
||||||
|
|
||||||
//! [meta data]
|
//! [meta data]
|
||||||
//: This is a comment for the translator.
|
//: This is a comment for the translator.
|
||||||
//= qtn_foo_bar
|
//= qtn_foo_bar
|
||||||
|
@ -1219,6 +1219,13 @@ void QObject::setObjectName(const QString &name)
|
|||||||
The event() function can be reimplemented to customize the
|
The event() function can be reimplemented to customize the
|
||||||
behavior of an object.
|
behavior of an object.
|
||||||
|
|
||||||
|
Make sure you call the parent event class implementation
|
||||||
|
for all the events you did not handle.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
\snippet code/src_corelib_kernel_qobject.cpp 52
|
||||||
|
|
||||||
\sa installEventFilter(), timerEvent(), QCoreApplication::sendEvent(),
|
\sa installEventFilter(), timerEvent(), QCoreApplication::sendEvent(),
|
||||||
QCoreApplication::postEvent()
|
QCoreApplication::postEvent()
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user