在 QTabWidget 选项卡中设置标签文本
我的表单上有 QTabWidget
,上面有两个选项卡。这些选项卡具有标准文本 Tab1 和 Tab2。 我怎样才能改变它?
I have QTabWidget
on my form and two tabs on it. These tabs have standard text Tab1 and Tab2.
How can I change it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
听起来您正在谈论 Qt Designer,因为当您通过界面添加
QTabWidget
时,它默认显示两个选项卡(称为“Tab 1”和“Tab 2”)。如果是这样,请单击要重命名的选项卡,然后在“属性编辑器”中单击(如果找不到它,请使用“视图”->“属性编辑器”确保其可见) em> 菜单项)向下滚动到底部并查找
currentTabText
属性。您可以在那里更改选项卡的名称。It sounds like you're talking about Qt Designer, since it defaults to showing two tabs (called "Tab 1" and "Tab 2") when you add a
QTabWidget
through the interface.If so, click on the tab you want to rename, then in the Property Editor (if you can't find it make sure it's visible by using the View->Property Editor menu item) scroll down to the bottom and look for the
currentTabText
property. You can change the tab's name right there.您可以在运行时使用它:
You can use this at runtime:
在 Qt Creator/Designer (2.4.1) 中,如果您似乎找不到 currentTabText 属性,则您可能已经在对象树中选择了选项卡本身。
确保选择 QTabWidget,在表单预览中选择选项卡时应该会自动发生(请参阅 richardwb 的答案)。
In Qt Creator/Designer (2.4.1), if you can't seem to find the currentTabText property, you have probably selected the tab itself in the the object tree.
Make sure to select the QTabWidget, which should happen automatically when selecting the tab in the form preview (see richardwb's answer).