• 5618阅读
  • 1回复

请问如何获取当前焦点Widget的指针? [复制链接]

上一主题 下一主题
离线xiston
 

只看楼主 倒序阅读 楼主  发表于: 2010-04-10
rt!
万分感谢!
离线xiston

只看该作者 1楼 发表于: 2010-04-10
fuck my life~~~弄了半天的问题刚提问完问题就在文档里面发现答案……
现自问自答了……

获取当前焦点的widget有两种函数:
QWidget * QApplication::focusWidget ()   [static]
Returns the application widget that has the keyboard input focus, or 0 if no widget in this application has the focus.
这个是全局的。

QWidget * QWidget::focusWidget () const
Returns the last child of this widget that setFocus had been called on. For top level widgets this is the widget that will get focus in case this window gets activated

This is not the same as QApplication::focusWidget(), which returns the focus widget in the currently active window.
这个在当前widget中调用,返回它的子widget指针,这个子widget设置了焦点。

调用这样的函数,可以让软键盘只在指定的widget编辑时显示出来~~
快速回复
限100 字节
 
上一个 下一个