是否可以通过选项卡编号引用 QTabWidget 的各个选项卡?
这里的问题非常快。我想知道我是否可以通过数字引用 QTabWidget 中的各个选项卡。这将为我节省大量时间,因为我在运行时生成未知数量的选项卡。我在 QT 文档中找不到任何内容,但我觉得这是一个应该包含的非常基本的功能。我在想这样的事情(不是真正的代码,只是一个想法,我意识到 tabNumber() 不存在):
ui->tabArea->tabNumber(12);
如果没有公共函数,也许还有其他方法?请不要建议按名称引用选项卡,因为这是不可能的(可能有 100 个选项卡),而且我已经尝试过。
Very quick question here. I was wondering if it is possible for me to reference individual tabs from a QTabWidget by number. This will save me a lot of time, as I am generating an unknown number of tabs during run-time. I could not find anything in the QT documentation, but I feel like this is a very basic feature that should be included. I am thinking something like this (not real code just an idea, I realize tabNumber() doesn't exist):
ui->tabArea->tabNumber(12);
If there isn't a public function, perhaps there's some other way? Please don't suggest referencing tabs by name because that is out of the question (potentially 100's of tabs), and I have already tried it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想要具有特定索引的选项卡,请使用 widget():
If you want the tab with a certain index, use widget():
我认为
setCurrentIndex()
方法就是您正在寻找的方法。I think the
setCurrentIndex()
method is what you are looking for.