[英]Is there a way, in PySide to style the tab buttons on a QtabWidget?
is there a way in PySide to style the tab buttons on the QtabWidget? PySide中有没有一种方法可以在QtabWidget上设置选项卡按钮的样式? I'm right now trying to make a costum styled widget, and I've styled every other element, but I can't seem to figure out how to style the QtabWidget... 我现在正在尝试制作一个Costum样式的小部件,并且已经对所有其他元素进行了样式设置,但是我似乎无法弄清楚如何设置QtabWidget的样式...
I was trying: 我正在尝试:
self.tabWidget = QtGui.QtabWidget(Form)
self.tabWidget.tab.setStyleSheet("some style goes here")
but I now know I cant reference the tab like that. 但是我现在知道我不能像这样引用该标签。 any help on this would be greatly appreciated. 任何帮助,将不胜感激。
You are looking for the QTabBar::tab
subcontrol. 您正在寻找QTabBar::tab
控件。
#!/usr/bin/env python
#-*- coding:utf-8 -*-
from PyQt4 import QtGui, QtCore
class MyWindow(QtGui.QTabWidget):
def __init__(self, parent=None):
super(MyWindow, self).__init__(parent)
self.setStyleSheet("""
QTabBar::tab {
color: #FF0000;
}
""")
for tabNumber in range(3):
widget = QtGui.QLabel(self)
widget.setText("This is widget #{0}".format(tabNumber))
self.addTab(widget, "Tab {0}".format(tabNumber))
if __name__ == "__main__":
import sys
app = QtGui.QApplication(sys.argv)
app.setApplicationName('MyWindow')
main = MyWindow()
main.show()
sys.exit(app.exec_())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.