我的列标签太大,如下例所示。如何将标题标签旋转到90度?你知道我怎么能这么简单吗?
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
data = {'Large Table Columns 1':['1','2','3'], 'Large Table Columns 2':['4','5','6'], 'Large Table Columns 3':['7','8','9']}
class MyTable(QTableWidget):
def __init__(self, data, *args):
QTableWidget.__init__(self, *args)
self.data = data
self.setmydata()
self.resizeColumnsToContents()
self.resizeRowsToContents()
def setmydata(self):
horHeaders = []
for n, key in enumerate(sorted(self.data.keys())):
horHeaders.append(key)
for m, item in enumerate(self.data[key]):
newitem = QTableWidgetItem(item)
self.setItem(m, n, newitem)
self.setHorizontalHeaderLabels(horHeaders)
def main(args):
app = QApplication(args)
table = MyTable(data, 5, 3)
table.show()
sys.exit(app.exec_())
if __name__=="__main__":
main(sys.argv)