QAbstractScrollAreaFilter Class Reference

#include <qabstractscrollarea_p.h>

Inheritance diagram for QAbstractScrollAreaFilter:

Inheritance graph
[legend]
Collaboration diagram for QAbstractScrollAreaFilter:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 82 of file qabstractscrollarea_p.h.

Public Member Functions

 QAbstractScrollAreaFilter (QAbstractScrollAreaPrivate *p)
bool eventFilter (QObject *o, QEvent *e)

Private Attributes

QAbstractScrollAreaPrivated


Constructor & Destructor Documentation

QAbstractScrollAreaFilter::QAbstractScrollAreaFilter ( QAbstractScrollAreaPrivate p  )  [inline]

Definition at line 86 of file qabstractscrollarea_p.h.

References QObject::setObjectName().

00086                                                              : d(p)
00087     { setObjectName(QLatin1String("qt_abstractscrollarea_filter")); }

Here is the call graph for this function:


Member Function Documentation

bool QAbstractScrollAreaFilter::eventFilter ( QObject o,
QEvent e 
) [inline, virtual]

Filters events if this object has been installed as an event filter for the watched object.

In your reimplementation of this function, if you want to filter the event out, i.e. stop it being handled further, return true; otherwise return false.

Example:

        class MainWindow : public QMainWindow
        {
        public:
            MainWindow();

        protected:
            bool eventFilter(QObject *obj, QEvent *ev);

        private:
            QTextEdit *textEdit;
        };

        MainWindow::MainWindow()
        {
            textEdit = new QTextEdit;
            setCentralWidget(textEdit);

            textEdit->installEventFilter(this);
        }

        bool MainWindow::eventFilter(QObject *obj, QEvent *event)
        {
            if (obj == textEdit) {
                if (event->type() == QEvent::KeyPress) {
                    QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
                    qDebug() << "Ate key press" << keyEvent->key();
                    return true;
                } else {
                    return false;
                }
            } else {
                // pass the event on to the parent class
                return QMainWindow::eventFilter(obj, event);
            }
        }

Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.

Warning:
If you delete the receiver object in this function, be sure to return true. Otherwise, Qt will forward the event to the deleted object and the program might crash.
See also:
installEventFilter()

Reimplemented from QObject.

Definition at line 88 of file qabstractscrollarea_p.h.

References d, o, QAbstractScrollAreaPrivate::viewport, and QAbstractScrollAreaPrivate::viewportEvent().

00089     { return (o == d->viewport ? d->viewportEvent(e) : false); }

Here is the call graph for this function:


Member Data Documentation

QAbstractScrollAreaPrivate* QAbstractScrollAreaFilter::d [private]

Definition at line 91 of file qabstractscrollarea_p.h.

Referenced by eventFilter().


The documentation for this class was generated from the following file:
Generated on Thu Mar 15 16:43:01 2007 for Qt 4.2 User's Guide by  doxygen 1.5.1