QFocusEvent Class

Die Klasse QFocusEvent enthält Ereignisparameter für Fokusereignisse von Widgets. Mehr...

Kopfzeile: #include <QFocusEvent>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
Vererbungen: QEvent

Öffentliche Funktionen

QFocusEvent(QEvent::Type type, Qt::FocusReason reason = Qt::OtherFocusReason)
bool gotFocus() const
bool lostFocus() const
Qt::FocusReason reason() const

Detaillierte Beschreibung

Fokusereignisse werden an Widgets gesendet, wenn sich der Fokus der Tastatureingabe ändert. Fokusereignisse treten aufgrund von Mausaktionen, Tastendrucken (wie Tab oder Backtab), dem Fenstersystem, Popup-Menüs, Tastaturkürzeln oder anderen anwendungsspezifischen Gründen auf. Der Grund für ein bestimmtes Fokusereignis wird von reason() im entsprechenden Event-Handler zurückgegeben.

Die Ereignisbehandler QWidget::focusInEvent(), QWidget::focusOutEvent(), QGraphicsItem::focusInEvent und QGraphicsItem::focusOutEvent() empfangen Fokusereignisse.

Siehe auch QWidget::setFocus(), QWidget::setFocusPolicy(), und Tastaturfokus in Widgets.

Dokumentation der Mitgliedsfunktionen

[explicit] QFocusEvent::QFocusEvent(QEvent::Type type, Qt::FocusReason reason = Qt::OtherFocusReason)

Konstruiert ein Fokus-Ereignis-Objekt.

Der Parameter type muss entweder QEvent::FocusIn oder QEvent::FocusOut sein. reason beschreibt die Ursache für die Änderung des Fokus.

bool QFocusEvent::gotFocus() const

Gibt true zurück, wenn type() QEvent::FocusIn ist; andernfalls wird false zurückgegeben.

bool QFocusEvent::lostFocus() const

Gibt true zurück, wenn type() QEvent::FocusOut ist; andernfalls wird false zurückgegeben.

Qt::FocusReason QFocusEvent::reason() const

Gibt den Grund für dieses Fokusereignis zurück.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.