Qt4:调整哪个小部件着重于开始 [英] Qt4: adjust which widget get focused on start

查看:162
本文介绍了Qt4:调整哪个小部件着重于开始的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我不重新实现 QMainWindow :: showEvent()(它将包含该widget的setFocus()方法),有什么办法让当窗口被加载时,一些小部件首先被聚焦?我使用Qt4的表单编辑器,但没有找到配置的地方。 可以设置 Qt Designer中的Tab Order 或Qt Creator中的Designer组件。




许多用户希望能够使用键盘在小部件之间导航并控制
。 Qt让用户在输入
小部件与 Tab Shift + Tab 键盘快捷键之间切换。默认选项卡
的顺序是基于构件的顺序。尽管
这个命令对许多用户来说可能是足够的,但是通常
明确地指定了tab键顺序,使得你的应用程序更容易被
使用。



设置制表符顺序



要进入制表符编辑模式, 编辑菜单,然后选择编辑
制表顺序。在这种模式下,窗体中的每个输入窗口小部件都显示一个
数字,表示按Tab键顺序的位置。因此,如果用户给
第一个输入控件输入焦点,然后按下tab键,
焦点将移动到第二个输入控件,等等。



通过点击
中每个数字的正确顺序来定义tab键顺序。您点击的第一个数字将变为红色,
表示标签顺序链中当前编辑的位置。与数字关联的
小部件将成为选项卡
的第一个订单链。点击另一个小部件将使它成为
标签顺序中的第二个,依此类推。



重复这个过程,直到您满意
表单 - 如果您看到
其余小部件已经按照正确的顺序,则不需要单击每个输入小部件。数字,您已经设置了订单的
,变成绿色,而那些
没有被点击的,仍然是蓝色。



如果你如果出现错误,只需双击任何数字或
,从表单的上下文菜单中选择重新开始以重新开始。如果
在表单上有许多小部件,并且希望在标签订单链的中间或结尾更改标签订单
,则可以在
的任意位置进行编辑。按 Ctrl ,然后点击您希望
开始的号码。或者,从上下文菜单中选择从这里开始



If I don't re-implement QMainWindow::showEvent() (which will contains a setFocus() method for that widget), is there any way to let some widget get focused first, when the window is loaded ? I use form editor of Qt4, but failed to find somewhere to configure that.

解决方案

You can set the Tab Order in Qt Designer or the Designer component in Qt Creator. The first widget in the tab order should get focus on load.

Many users expect to be able to navigate between widgets and controls using only the keyboard. Qt lets the user navigate between input widgets with the Tab and Shift+Tab keyboard shortcuts. The default tab order is based on the order in which widgets are constructed. Although this order may be sufficient for many users, it is often better to explicitly specify the tab order to make your application easier to use.

Setting the Tab Order

To enter tab order editing mode, open the Edit menu and select Edit Tab Order. In this mode, each input widget in the form is shown with a number indicating its position in the tab order. So, if the user gives the first input widget the input focus and then presses the tab key, the focus will move to the second input widget, and so on.

The tab order is defined by clicking on each of the numbers in the correct order. The first number you click will change to red, indicating the currently edited position in the tab order chain. The widget associated with the number will become the first one in the tab order chain. Clicking on another widget will make it the second in the tab order, and so on.

Repeat this process until you are satisfied with the tab order in the form -- you do not need to click every input widget if you see that the remaining widgets are already in the correct order. Numbers, for which you already set the order, change to green, while those which are not clicked yet, remain blue.

If you make a mistake, simply double click outside of any number or choose Restart from the form's context menu to start again. If you have many widgets on your form and would like to change the tab order in the middle or at the end of the tab order chain, you can edit it at any position. Press Ctrl and click the number from which you want to start. Alternatively, choose Start from Here in the context menu.

这篇关于Qt4:调整哪个小部件着重于开始的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆