如何聚焦新标签?
我可以使用添加新选项卡 qtabwidget->addTab(newtab, title);
但是否可以专注于此 我的代码中的选项卡?
谢谢
I was able to add a new tab using
qtabwidget->addTab ( newtab, title );
But is it possible to focus on this
tab in my code?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用指向添加的小部件的指针或数字索引。
请参阅:
http://doc.qt.io/qt-5/qtabwidget.html #setCurrentWidget
http://doc.qt.io/qt -5/qtabwidget.html#currentIndex-prop
例如,如果您有一个带有 3 个选项卡的选项卡小部件,您可以像这样关注第二个选项卡:
如果您只想使用指向您的小部件的指针 ( QWidget 类型的 MyWidget) 那么这里是另一个例子:
You can use either the pointer to the added widget or a numeric index.
See:
http://doc.qt.io/qt-5/qtabwidget.html#setCurrentWidget
http://doc.qt.io/qt-5/qtabwidget.html#currentIndex-prop
For example, if you have a tab widget with say 3 tabs, you can focus on the 2nd tab like this:
If you just want to use the pointer to your widget (MyWidget of type QWidget) then here is another example:
计算选项卡总数并设置最后一个:
Count the total number of tabs and set the last one:
.h.cpp
.h
.cpp