• 8755阅读
  • 6回复

怎样设置Widget的焦点? [复制链接]

上一主题 下一主题
离线wsbd008
 
只看楼主 正序阅读 楼主  发表于: 2009-12-23
我的窗口里面有三个widget, 都是我自己写的,一个player,一个editor, 一个timer。

然后我在MainWindow里面添加了这三个控件,每次程序启动焦点都在player的音量控制器上,我想让程序刚开始运行的时候焦点设置在editor里面,怎么设置啊?
离线wsbd008
只看该作者 6楼 发表于: 2009-12-27
引用第1楼yangfanxing于2009-12-23 21:57发表的  :
void QWidget::setTabOrder ( QWidget * first, QWidget * second )
setTabOrder(a, b); // a to b
setTabOrder(b, c); // a to b to c
setTabOrder(c, d); // a to b to c to d
.......


额,不行。。。

这个和player里面的widget有没有关系啊?player里面也有几个widget,它们的tab顺序我没有设置。。。
离线xtfllbl

只看该作者 5楼 发表于: 2009-12-24
focusPolicy : Qt::FocusPolicy
This property holds the way the widget accepts keyboard focus.

The policy is Qt::TabFocus if the widget accepts keyboard focus by tabbing, Qt::ClickFocus if the widget accepts focus by clicking, Qt::StrongFocus if it accepts both, and Qt::NoFocus (the default) if it does not accept focus at all.

You must enable keyboard focus for a widget if it processes keyboard events. This is normally done from the widget's constructor. For instance, the QLineEdit constructor calls setFocusPolicy(Qt::StrongFocus).

If the widget has a focus proxy, then the focus policy will be propagated to it.

Access functions:

Qt::FocusPolicy    focusPolicy () const
void    setFocusPolicy ( Qt::FocusPolicy policy )
上海欢迎您
离线benbenmajia

只看该作者 4楼 发表于: 2009-12-24
有没有可以设置focus的
安然.....
离线wd007

只看该作者 3楼 发表于: 2009-12-23
楼上正解。
欢迎访问我的博客,一起学习提高
http://blog.csdn.net/qter_wd007
离线yangfanxing
只看该作者 2楼 发表于: 2009-12-23
另外要是在Desinger下可以F4编辑Tab顺序~
PHPWind好恶心。。。不想看这种界面。。。
离线yangfanxing
只看该作者 1楼 发表于: 2009-12-23
void QWidget::setTabOrder ( QWidget * first, QWidget * second )

setTabOrder(a, b); // a to b
setTabOrder(b, c); // a to b to c
setTabOrder(c, d); // a to b to c to d

你把player设为a
PHPWind好恶心。。。不想看这种界面。。。
快速回复
限100 字节
 
上一个 下一个