Logo Search packages:      
Sourcecode: qt4-x11 version File versions

bool QObject::event ( QEvent e  )  [virtual, inherited]

This virtual function receives events to an object and should return true if the event e was recognized and processed.

The event() function can be reimplemented to customize the behavior of an object.

See also:
installEventFilter(), timerEvent(), QApplication::sendEvent(), QApplication::postEvent(), QWidget::event()

Reimplemented in QSettings, QCoreApplication, QSocketNotifier, QGraphicsScene, QGraphicsView, QAbstractItemView, QHeaderView, QListView, QListWidget, QTableWidget, QTreeWidget, QAction, QApplication, QClipboard, QShortcut, QWidget, QWidgetAction, QX11EmbedWidget, QX11EmbedContainer, QMotifStyle, QCompleter, QSystemTrayIcon, QAbstractButton, QAbstractScrollArea, QAbstractSlider, QAbstractSpinBox, QCalendarWidget, QCheckBox, QComboBox, QDateTimeEdit, QDial, QDialogButtonBox, QDockWidget, QFocusFrame, QFontComboBox, QFrame, QGroupBox, QLabel, QLCDNumber, QLineEdit, QMainWindow, QMenu, QMenuBar, QProgressBar, QPushButton, QRadioButton, QRubberBand, QScrollArea, QScrollBar, QSizeGrip, QSlider, QSpinBox, QSplashScreen, QSplitter, QSplitterHandle, QStackedWidget, QStatusBar, QTabBar, QTabWidget, QTextBrowser, QTextEdit, QToolBar, QToolBox, QToolButton, QWorkspace, QGLWidget, Q3TextEdit, Q3ButtonGroup, Q3DateEdit, Q3TimeEdit, Q3DockWindow, Q3MainWindow, Q3ToolBar, and Q3WidgetStack.

Definition at line 991 of file qobject.cpp.

References QObject::childEvent(), QObject::customEvent(), QMetaObject::invokeMethod(), QList< T >::isEmpty(), QAbstractEventDispatcher::registeredTimers(), QObject::timerEvent(), QEvent::type(), and QAbstractEventDispatcher::unregisterTimers().

Referenced by QCoreApplication::compressEvent(), QApplication::compressEvent(), QClipboard::event(), QCompleter::event(), QMotifStyle::event(), QWidget::event(), QAction::event(), QSettings::event(), QCoreApplication::event(), QSocketNotifier::event(), QSystemTrayIcon::event(), QGraphicsScene::event(), and QCoreApplication::removePostedEvents().

{
    switch (e->type()) {
    case QEvent::Timer:
        timerEvent((QTimerEvent*)e);
        break;

    case QEvent::ChildAdded:
    case QEvent::ChildPolished:
#ifdef QT3_SUPPORT
    case QEvent::ChildInserted:
#endif
    case QEvent::ChildRemoved:
        childEvent((QChildEvent*)e);
        break;

    case QEvent::DeferredDelete:
        delete this;
        break;

    case QEvent::MetaCall:
        {
            Q_D(QObject);
            QMetaCallEvent *mce = static_cast<QMetaCallEvent*>(e);
            QObject *previousSender = d->currentSender;
            int previousFrom = d->currentSenderSignalIdStart;
            int previousTo = d->currentSenderSignalIdEnd;
            d->currentSender = const_cast<QObject*>(mce->sender());
            d->currentSenderSignalIdStart = mce->signalIdStart();
            d->currentSenderSignalIdEnd = mce->signalIdEnd();
#if defined(QT_NO_EXCEPTIONS)
            qt_metacall(QMetaObject::InvokeMetaMethod, mce->id(), mce->args());
#else
            try {
                qt_metacall(QMetaObject::InvokeMetaMethod, mce->id(), mce->args());
            } catch (...) {
                QReadLocker locker(QObjectPrivate::readWriteLock());
                if (QObjectPrivate::isValidObject(this)) {
                    d->currentSender = previousSender;
                    d->currentSenderSignalIdStart = previousFrom;
                    d->currentSenderSignalIdEnd = previousTo;
                }
                throw;
            }
#endif
            QReadLocker locker(QObjectPrivate::readWriteLock());
            if (QObjectPrivate::isValidObject(this)) {
                d->currentSender = previousSender;
                d->currentSenderSignalIdStart = previousFrom;
                d->currentSenderSignalIdEnd = previousTo;
            }
            break;
        }

    case QEvent::ThreadChange: {
        QThreadData *threadData = d_func()->threadData;
        QAbstractEventDispatcher *eventDispatcher = threadData->eventDispatcher;
        if (eventDispatcher) {
            QList<QPair<int, int> > timers = eventDispatcher->registeredTimers(this);
            if (!timers.isEmpty()) {
                eventDispatcher->unregisterTimers(this);
                QMetaObject::invokeMethod(this, "_q_reregisterTimers", Qt::QueuedConnection,
                                          Q_ARG(void*, (new QList<QPair<int, int> >(timers))));
            }
        }
        break;
    }

    default:
        if (e->type() >= QEvent::User) {
            customEvent(e);
            break;
        }
        return false;
    }
    return true;
}


Generated by  Doxygen 1.6.0   Back to index