返回介绍

QFocusEvent Class

发布于 2019-10-04 15:00:16 字数 3223 浏览 1112 评论 0 收藏 0

The QFocusEvent class contains event parameters for widget focus events. More...

#include <qevent.h>

Inherits QEvent.

List of all member functions.

Public Members

  • QFocusEvent ( Typetype )
  • bool gotFocus () const
  • bool lostFocus () const
  • enum Reason { Mouse, Tab, Backtab, ActiveWindow, Popup, Shortcut, Other }

Static Public Members

  • Reason reason ()
  • void setReason ( Reasonreason )
  • void resetReason ()

Detailed Description

The QFocusEvent class contains event parameters for widget focus events.

Focus events are sent to widgets when the keyboard input focus changes. Focus events occur due to mouse actions, keypresses (e.g. Tab or Backtab), the window system, popup menus, keyboard shortcuts or other application specific reasons. The reason for a particular focus event is returned by reason() in the appropriate event handler.

The event handlers QWidget::focusInEvent() and QWidget::focusOutEvent() receive focus events.

Use setReason() to set the reason for all focus events, and resetReason() to set the reason for all focus events to the reason in force before the last setReason() call.

See also QWidget::setFocus(), QWidget::focusPolicy and Event Classes.


Member Type Documentation

QFocusEvent::Reason

This enum specifies why the focus changed.

  • QFocusEvent::Mouse - because of a mouse action.
  • QFocusEvent::Tab - because of a Tab press.
  • QFocusEvent::Backtab - because of a Backtab press (possibly including Shift/Control, e.g. Shift+Tab).
  • QFocusEvent::ActiveWindow - because the window system made this window (in)active.
  • QFocusEvent::Popup - because the application opened/closed a popup that grabbed/released focus.
  • QFocusEvent::Shortcut - because of a keyboard shortcut.
  • QFocusEvent::Other - any other reason, usually application-specific.

See the keyboard focus overview for more about focus.


Member Function Documentation

QFocusEvent::QFocusEvent ( Typetype )

Constructs a focus event object.

The type parameter must be either QEvent::FocusIn or QEvent::FocusOut.

bool QFocusEvent::gotFocus () const

Returns TRUE if the widget received the text input focus; otherwise returns FALSE.

bool QFocusEvent::lostFocus () const

Returns TRUE if the widget lost the text input focus; otherwise returns FALSE.

Reason QFocusEvent::reason () [static]

Returns the reason for this focus event.

See also setReason().

void QFocusEvent::resetReason () [static]

Resets the reason for all future focus events to the value before the last setReason() call.

See also reason() and setReason().

void QFocusEvent::setReason ( Reasonreason ) [static]

Sets the reason for all future focus events to reason.

See also reason() and resetReason().

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文