QTableView的获取焦点

来源:互联网 发布:请你列举三个机构域名 编辑:程序博客网 时间:2024/05/16 09:32

想取消qtableview获取焦点的功能,查了qt4.1.0文档,仔细看了下,用setFocusPolicy设置

tableView->setFocusPolicy(Qt::NoFocus)

其中qt4.1.0文档关于enum Qt::FocusPolicy说明如下:

This enum type defines the various policies a widget can have with respect to acquiring keyboard focus.

ConstantValueDescription
Qt::TabFocus0x1the widget accepts focus by tabbing.
Qt::ClickFocus0x2the widget accepts focus by clicking.
Qt::StrongFocusTabFocus | ClickFocus | 0x8the widget accepts focus by both tabbing and clicking. On Mac OS X this will also be indicate that the widget accepts tab focus when in 'Text/List focus mode'.
Qt::WheelFocusStrongFocus | 0x4like Qt::StrongFocus plus the widget accepts focus by using the mouse wheel.
Qt::NoFocus0the widget does not accept focus.

而关于enum Qt::FocusReason的说明如下:

This enum specifies why the focus changed. It will be passed through QWidget::setFocus and can be retrieved in the QFocusEvent sent to the widget upon focus change.

ConstantValueDescription
Qt::MouseFocusReason0A mouse action occurred.
Qt::TabFocusReason1The Tab key was pressed.
Qt::BacktabFocusReason2A Backtab occurred. The input for this may include the Shift or Control keys; e.g. Shift+Tab.
Qt::ActiveWindowFocusReason3The window system made this window either active or inactive.
Qt::PopupFocusReason4The application opened/closed a popup that grabbed/released the keyboard focus.
Qt::ShortcutFocusReason5The user typed a label's buddy shortcut
Qt::MenuBarFocusReason6The menu bar took focus.
Qt::OtherFocusReason7Another reason, usually application-specific. No good reason, really.

原来两者区别挺大的,学习了.

资料参考:Qt 4.1.0文档

原创粉丝点击