Qt中的焦点事件
2015-02-14 11:06
288 查看
Qt中的焦点事件
分类: Qt 2012-07-13 14:59 8555人阅读 评论(2) 收藏 举报
qtos
目录(?)[+]
在应用程序中,都会有一个当前窗口,即当前获得焦点事件的窗口,这个窗口可以接受键盘的输入。当应用有多个窗口时就要使用焦点事件了!
Qt中有很好的焦点事件管理,我在这里抛砖引玉了。一个空间要先设置它焦点事件的模式,即窗口如何接受焦点事件(通过鼠标单击、Tab键、不接受焦点事件等)
void setFocusPolicy ( Qt::FocusPolicy policy )
就是设置焦点事件模式的函数,其中函数的参数为
Constant Value Description
Qt::TabFocus 0x1 the widget accepts focus by tabbing.
Qt::ClickFocus 0x2 the widget accepts focus by clicking.
Qt::StrongFocus TabFocus | ClickFocus | 0x8 the 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::WheelFocus StrongFocus | 0x4 like Qt::StrongFocus plus the widget accepts focus by using the mouse wheel.
Qt::NoFocus 0 the widget does not accept focus.
如果想通过单击鼠标获取焦点事件,那么就可以选择参数Qt::ClickFocus,其他不赘述。
当前有焦点事件的窗口只能有一个,当一个窗口获取焦点事件或失去焦点事件时,可能需要相应的操作,或者如何判断一个才窗口有没有焦点事件。Qt中亦有相应的函数。
void QWidget::focusInEvent ( QFocusEvent * event ) [virtual protected]
void QWidget::focusOutEvent ( QFocusEvent * event ) [virtual protected]
这两个就是窗口获取或失去焦点事件的函数,需要我们重写(好多窗口都是从QWidget继承这两个函数的)
bool hasFocus () const
这个函数就是判断当前窗口有没有焦点事件的,返回布尔值。
void QWidget::setFocus ( Qt::FocusReason reason )
void QWidget::clearFocus ()
这两个函数就是设置或清除焦点事件的。
要想知道更多,只需要在“Qt助手”的“索引”中输入“Focus”,自己动手吧!!
分类: Qt 2012-07-13 14:59 8555人阅读 评论(2) 收藏 举报
qtos
目录(?)[+]
在应用程序中,都会有一个当前窗口,即当前获得焦点事件的窗口,这个窗口可以接受键盘的输入。当应用有多个窗口时就要使用焦点事件了!
Qt中有很好的焦点事件管理,我在这里抛砖引玉了。一个空间要先设置它焦点事件的模式,即窗口如何接受焦点事件(通过鼠标单击、Tab键、不接受焦点事件等)
void setFocusPolicy ( Qt::FocusPolicy policy )
就是设置焦点事件模式的函数,其中函数的参数为
Constant Value Description
Qt::TabFocus 0x1 the widget accepts focus by tabbing.
Qt::ClickFocus 0x2 the widget accepts focus by clicking.
Qt::StrongFocus TabFocus | ClickFocus | 0x8 the 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::WheelFocus StrongFocus | 0x4 like Qt::StrongFocus plus the widget accepts focus by using the mouse wheel.
Qt::NoFocus 0 the widget does not accept focus.
如果想通过单击鼠标获取焦点事件,那么就可以选择参数Qt::ClickFocus,其他不赘述。
当前有焦点事件的窗口只能有一个,当一个窗口获取焦点事件或失去焦点事件时,可能需要相应的操作,或者如何判断一个才窗口有没有焦点事件。Qt中亦有相应的函数。
void QWidget::focusInEvent ( QFocusEvent * event ) [virtual protected]
void QWidget::focusOutEvent ( QFocusEvent * event ) [virtual protected]
这两个就是窗口获取或失去焦点事件的函数,需要我们重写(好多窗口都是从QWidget继承这两个函数的)
bool hasFocus () const
这个函数就是判断当前窗口有没有焦点事件的,返回布尔值。
void QWidget::setFocus ( Qt::FocusReason reason )
void QWidget::clearFocus ()
这两个函数就是设置或清除焦点事件的。
要想知道更多,只需要在“Qt助手”的“索引”中输入“Focus”,自己动手吧!!
相关文章推荐
- Qt获得焦点和失去焦点处理事件 (Focus事件)
- QT的键盘事件及焦点设置
- Qt中的焦点事件
- Qt中使用事件过滤器来处理键盘焦点
- Qt中的键盘事件,以及焦点的设置(比较详细)
- Qt中使用事件过滤器来处理键盘焦点
- Qt中的键盘事件以及焦点设置
- QT 焦点事件(4种方式的解释,还有委托焦点)
- Qt获得焦点和失去焦点处理事件 (Focus事件)
- 关键词:键盘触发事件、QList用法、清除/获得焦点、CSS、Qt初学教程
- Qt焦点事件
- Qt获得焦点和失去焦点处理事件 (Focus事件)
- Qt中的焦点事件
- Qt中的焦点事件
- Qt中的焦点事件
- QT 获取焦点失去焦点事件
- Qt获得焦点和失去焦点处理事件 (Focus事件)
- Qt焦点事件
- Qt焦点事件
- Qt中的焦点事件