2
Как контролировать сортировки индикатор стрелки на QTableView
Когда QTableView
создан Я хочу, чтобы индикатор сортировки «стрелка», чтобы показать на колонке в середине. Стрелка должна быть направлена вниз. Как достичь этого?
from PyQt4 import QtCore, QtGui
app = QtGui.QApplication([])
class Model(QtCore.QAbstractTableModel):
def __init__(self):
QtCore.QAbstractTableModel.__init__(self)
self.items = [[1, 'one', 'ONE'], [2, 'two', 'TWO'], [3, 'three', 'THREE']]
def rowCount(self, parent=QtCore.QModelIndex()):
return 3
def columnCount(self, parent=QtCore.QModelIndex()):
return 3
def data(self, index, role):
if not index.isValid(): return
if role == QtCore.Qt.DisplayRole:
return self.items[index.row()][index.column()]
tableModel=Model()
tableView=QtGui.QTableView()
tableView.setModel(tableModel)
tableView.setSortingEnabled(True)
tableView.show()
app.exec_()