返回介绍

QFocusData Class

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

The QFocusData class maintains the list of widgets in the focus chain. More...

#include <qfocusdata.h>

List of all member functions.

Public Members

  • QWidget * focusWidget () const
  • QWidget * home ()
  • QWidget * next ()
  • QWidget * prev ()
  • int count () const

Detailed Description

The QFocusData class maintains the list of widgets in the focus chain.

This read-only list always contains at least one widget (i.e. the top-level widget). It provides a simple cursor which can be reset to the current focus widget using home(), or moved to its neighboring widgets using next() and prev(). You can also retrieve the count() of the number of widgets in the list. The list is a loop, so if you keep iterating, for example using next(), you will never come to the end.

Some widgets in the list may not accept focus. Widgets are added to the list as necessary, but not removed from it. This lets widgets change focus policy dynamically without disrupting the focus chain the user experiences. When a widget disables and re-enables tab focus, its position in the focus chain does not change.

When reimplementing QWidget::focusNextPrevChild() to provide special focus flow, you will usually call QWidget::focusData() to retrieve the focus data stored at the top-level widget. A top-level widget's focus data contains the focus list for its hierarchy of widgets.

The cursor may change at any time.

This class is not thread-safe.

See also QWidget::focusNextPrevChild(), QWidget::setTabOrder(), QWidget::focusPolicy and Miscellaneous Classes.


Member Function Documentation

int QFocusData::count () const

Returns the number of widgets in the focus chain.

QWidget* QFocusData::focusWidget () const

Returns the widgets in the hierarchy that are in the focus chain.

QWidget* QFocusData::home ()

Moves the cursor to the focusWidget() and returns that widget. You must call this before next() or prev() to iterate meaningfully.

QWidget* QFocusData::next ()

Moves the cursor to the next widget in the focus chain. There is always a next widget because the list is a loop.

QWidget* QFocusData::prev ()

Moves the cursor to the previous widget in the focus chain. There is always a previous widget because the list is a loop.

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

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

发布评论

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