例如,在第三个垂直标题行中添加QComboBox而不是标签的正确方法是什么。我真的不明白QHeaderView的实际运作方式。
感谢您的帮助。
import sys
import string
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class Header(QHeaderView):
def __init__(self, parent=None):
super(Header, self).__init__(Qt.Horizontal, parent)
class Table(QTableWidget):
def __init__(self, parent=None):
super(Table, self).__init__(parent)
self.setHorizontalHeader(Header(self))
self.setColumnCount(1)
self.setRowCount(3)
self.setColumnWidth(0,100)
self.setHorizontalHeaderLabels(['1'])
self.setVerticalHeaderLabels(['1','2'])
self.combo = QComboBox(self.verticalHeader())
self.combo.addItem('a')
self.combo.addItem('b')
if __name__ == '__main__':
app = QApplication(sys.argv)
t = Table()
t.show()
app.exec_()
sys.exit()