如何自动检测 Qt 对话框中无序选项卡导航?
通常,对话框希望通过大致对应于阅读书籍的顺序的对话框以有序的方式进行选项卡导航。
当团队的工程师将新字段添加到对话框时,新的小部件通常无法按选项卡正确的顺序插入。
任何人都可以想出一种方法来自动检测对话框中的选项卡导航顺序小部件吗?
Typically, a dialog wishes to have tab navigation proceed in an orderly fashion through a dialog that roughly corresponds to the order of reading a book.
When new fields are added to a dialog by engineers on a team, the new widgets can often not be inserted in tab correct order.
Can anyone think of a way to automate the detection of out of tab navigation order widgets within a dialog?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您正在谈论 QtDesigner *.ui 文件。
当 ui 文件(实际上是 xml 文件)中的
GridLayout
/FormLayout
项的顺序与视觉顺序(从左到右、从上到下)不同时,就会发生乱序 Tab 键切换。到底部)。像这样:请注意,第三行位于第一行之前,这意味着在生成的代码中(以及动态加载 ui 时),第三行中的小部件将首先添加,并且将按 Tab 键顺序排在第一位。
您可以在 ui 文件上使用以下 XLST 来“修复”制表符顺序,它会删除所有手动设置的制表位并按视觉顺序排列 xml 项目。
检测但不解决问题有点困难,因为必须考虑手动设置的制表位。基本算法如下:
部分重新排列列表,一次一对(例如QWidget.setTabOrder
) )。I assume you're speaking about QtDesigner *.ui files.
Out of order tabbing occurs when the order of
GridLayout
/FormLayout
items in a ui file (actually xml file) differs from the visual order (left-to-right, top-to-bottom). Like this:Note that the third row comes before the first, which means in the generated code (and also when loading ui dynamically) the widget from the third row will be added first and will come first in the tab order.
Here's the XLST you can use on a ui file to "fix" the tab order, it removes all manually set tab stops and arranges xml items in visual order.
Detecting but not fixing the problem is a bit harder, because manually set tab stops must be taken into account. Basic algorithm is as follows:
<tabstops>
section in the xml, one pair at a time (likeQWidget.setTabOrder
does it).听起来你有一个带有 QTabWidget 的 .ui 文件和多个页面都在 .ui 文件中。我建议把事情分开一点。将每个选项卡单独实现为一个小部件,这也可以在设计器中。那么 TabWidget 本身有两个选项。在设计器中创建所有选项卡,并将内容提升到需要进入该页面的小部件类。或者将 TabWidget 完全留空,并使用适当的子小部件在代码中填充它。
It sounds like you have a .ui file with a QTabWidget and a multitude of pages all in on .ui file. I would suggest splitting things up a little bit more. Implement each Tab as a widget by itself, this can be in the desginer too. Then you have two options for the TabWidget itself. Create all the tabs in the designer and promote the content to the widget class that needs to go on that page. Or leave the TabWidget completely empty and populate it in code with the appropriate subwidgets.