このページでは

QFocusEvent Class

QFocusEvent クラスには、ウィジェットのフォーカスイベントに関するイベントパラメータが含まれています。詳細...

ヘッダー: #include <QFocusEvent>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
継承元: QEvent

パブリック関数

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

プロテクトされた関数

QFocusEvent(QFocusEvent &&)
QFocusEvent &operator=(QFocusEvent &&)
QFocusEvent &operator=(const QFocusEvent &other)

詳細な説明

フォーカスイベントは、キーボード入力のフォーカスが変更されたときにウィジェットに送信されます。フォーカスイベントは、マウスの操作、キーの押下(Tab やBacktab など)、ウィンドウシステム、ポップアップメニュー、キーボードショートカット、またはその他のアプリケーション固有の理由によって発生します。特定のフォーカスイベントの発生理由は、適切なイベントハンドラ内のreason() によって返されます。

イベントハンドラQWidget::focusInEvent()、QWidget::focusOutEvent()、QGraphicsItem::focusInEvent 、およびQGraphicsItem::focusOutEvent() は、フォーカスイベントを受け取ります。

「 QWidget::setFocus()」、「QWidget::setFocusPolicy()」、および「ウィジェットにおけるキーボードフォーカス」も参照してください 。

メンバ関数のドキュメント

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

フォーカスイベントオブジェクトを作成します。

type パラメータには、QEvent::FocusIn またはQEvent::FocusOut のいずれかを指定する必要があります。reason は、フォーカスの変化の原因を表します。

[protected delete] QFocusEvent::QFocusEvent(QFocusEvent &&)

QFocusEvent のインスタンスをmove-constructで生成します。この関数は削除されています。

bool QFocusEvent::gotFocus() const

type() がQEvent::FocusIn の場合、true を返します。それ以外の場合は false を返します。

bool QFocusEvent::lostFocus() const

type() がQEvent::FocusOut の場合、true を返します。それ以外の場合は false を返します。

Qt::FocusReason QFocusEvent::reason() const

このフォーカスイベントの原因を返します。

[protected delete] QFocusEvent &QFocusEvent::operator=(QFocusEvent &&)

other をこのQFocusEvent インスタンスに割り当てます。この関数は削除されます。

[noexcept protected default] QFocusEvent &QFocusEvent::operator=(const QFocusEvent &other)

other をこのQFocusEvent インスタンスにコピーして割り当てます。

© 2026 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.