Qt: define Tab Order programmatically

不问归期 提交于 2019-12-10 16:27:28

问题


I've created 2 widget with Desinger (Widget1 and Widget2) , each one has it's tab order defined. A third widget (Widget3 )is defined programmatically and contains the above 2 widget in a vertical layout. In on a symbian non touch device. When I focus on widget3 I want to give the focus to widget1. Then go from widget1 to widget2 using the phone arrow when I reach the end of the widget1 tab chain. What is the proper way of doing this?


回答1:


From Qt Documentation for,

void QWidget::setTabOrder ( QWidget * first, QWidget * second )   [static]

which states that, Puts the second widget after the first widget in the focus order.

So for you, the first widget will be your Widget3 and second widget will be your Widget1. (if i understood the question correctly)

Besides that, there are examples available regarding the usage of this function in the link I provided above. You can use it.

Hope it helps..




回答2:


It is also possible to take advantage of the default tab order by set by item construction order. So just edit the .ui file XML:

<item>
     ... //Automatically assign with tab order X
</item>
<item>
     ... //Automatically assign with tab order X+1
</item>

In the order you wish the tab order to be.



来源:https://stackoverflow.com/questions/3307758/qt-define-tab-order-programmatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!