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

void QWidget::keyPressEvent ( QKeyEvent event  )  [protected, virtual, inherited]

This event handler, for event event, can be reimplemented in a subclass to receive key press events for the widget.

A widget must call setFocusPolicy() to accept focus initially and have focus in order to receive a key press event.

If you reimplement this handler, it is very important that you call the base class implementation if you do not act upon the key.

The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored, so that the widget's parent can interpret it.

Note that QKeyEvent starts with isAccepted() == true, so you do not need to call QKeyEvent::accept() - just do not call the base class implementation if you act upon the key.

See also:
keyReleaseEvent(), setFocusPolicy(), focusInEvent(), focusOutEvent(), event(), QKeyEvent, {Tetrix Example}

Reimplemented in PictureFlow, MainWindow, TetrixBoard, MandelbrotWidget, TextEdit, TetrixBoard, QWebView, QDialog, QMessageBox, QGraphicsView, QAbstractItemView, QTreeView, QAbstractButton, QAbstractScrollArea, QAbstractSlider, QAbstractSpinBox, QCalendarWidget, QComboBox, QDateTimeEdit, QLabel, QLineEdit, QMdiSubWindow, QMenu, QMenuBar, QPlainTextEdit, QPushButton, QTabBar, QTabWidget, QTextBrowser, QTextEdit, Q3FileDialog, Q3IconView, Q3ListBox, Q3ListView, Q3Table, Q3DataTable, Q3TextBrowser, Q3TextEdit, Q3ComboBox, Q3Header, and FindWidget.

Definition at line 7521 of file qwidget.cpp.

References QWidget::close(), QKeyEvent::key(), and QWidget::windowType().

Referenced by QWidget::event(), FindWidget::keyPressEvent(), QCalendarWidget::keyPressEvent(), QWebView::keyPressEvent(), MandelbrotWidget::keyPressEvent(), and Q3TextEdit::keyPressEvent().

    if ((windowType() == Qt::Popup) && event->key() == Qt::Key_Escape) {
    } else {

Generated by  Doxygen 1.6.0   Back to index