将关闭按钮放在QTabWidget上 [英] Putting a close button on QTabWidget
问题描述
我正在使用QTabWidget
在一个窗口中呈现多个文档,并且我想在每个选项卡上绘制一个关闭按钮.我使用的是 Vista 和 Qt4 ,因此选项卡小部件是本机Windows控件;这可能会影响可行性.
I'm using a QTabWidget
to render multiple documents in a window, and I want to draw a close button on each tab. I'm using Vista and Qt4, so the tab widget is a native windows control; this may affect the feasibility.
有人知道是否可以使用QTabWidget
控件执行此操作,还是我必须创建一个自定义窗口小部件?如果创建一个新的窗口部件是唯一的选择,那么任何指针将不胜感激.我对Qt比较陌生.
Does anyone know if it is possible to do this using the QTabWidget
control, or do I have to create a custom widget? If creating a new widget is the only option, any pointers would be much appreciated; I'm relatively new to Qt.
推荐答案
当前无法使用库存的QTabWidget进行此操作,但是即将推出的Qt 4.5(计划于2009年3月发布)将具有能够向选项卡手动或通过以下方式添加关闭按钮设置QTabBar.TabsClosable
属性.
Currently there is no way to do this with the stock QTabWidget, however the upcoming Qt 4.5 (planned to be released in March 2009) will have the ability to add close buttons to tabs either manually or by setting a QTabBar.TabsClosable
property.
直到那时,获取关闭按钮的唯一方法是将QTabWidget
或QTabBar
子类化,并手动添加(可能,但并不琐碎).
Until then, the only way to get close buttons is to subclass QTabWidget
or QTabBar
and add it manually (possible, but not trivial).
这篇关于将关闭按钮放在QTabWidget上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!