I would like to add an icon at the top left of the QTabWidget
. I don't want to add an icon for each tab. How to do that using a stylesheet or programmatically in C++?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Stylesheet below will add an image to the left of all tabs, but not to individual tabs. However, it is very likely that you'll need to tweak other attributes in the CSS to polish the final result.
QTabWidget > QTabBar {
background: url(url-to-your-corner-image);
background-repeat: norepeat;
margin-top: 10px; /* whatever needed to center the image vertically */
}
QTabWidget > QTabBar::tab:first {
margin-left: 10px; /* at least the width of your image */
}
回答2:
You can add a first tab with a fixed stylesheet : TabWidget stylesheet example