简体   繁体   English

将焦点放在第一个小部件上

[英]Set focus to the first widget

I have a dialog with tabs, and each tab has some check blocks and input blocks. 我有一个带有选项卡的对话框,每个选项卡都有一些检查块和输入块。

I think if I do not set any focus order, the order is defined in terms of the order in which those widgets are added. 我认为,如果我未设置任何焦点顺序,则该顺序是根据这些小部件的添加顺序来定义的。 I am fine with the initial order. 我可以接受最初的订单。

After users tab and change focus, I wanted to reset the focus back to the first widget. 用户标签并更改焦点后,我想将焦点重置回第一个小部件。 Because the widget tree is constructed top-down in my case, I think I can traverse children of each widget node to find the first widget. 因为在我的情况下小部件树是自上而下构造的,所以我认为可以遍历每个小部件节点的子代以找到第一个小部件。

Is there a better way to do? 有更好的方法吗? Will children be stored in the order they are added? 是否按照添加顺序存储子项?

您可以使用QWidget::nextInFocusChain方法来检索必须获得焦点的第一QWidget::nextInFocusChain部件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM