1
我需要添加一個額外的列到QFileSystemModel。我已經看到了答案:QT - adding own column to QFileSystemModel
有人會告訴我如何可以正確定義pyqt4中的子類嗎?pyqt:添加自定義列到QFileSystemModel
我需要添加一個額外的列到QFileSystemModel。我已經看到了答案:QT - adding own column to QFileSystemModel
有人會告訴我如何可以正確定義pyqt4中的子類嗎?pyqt:添加自定義列到QFileSystemModel
你幾乎可以複製粘貼C++代碼。這裏是pyqt的實現:
class YourSystemModel(QtGui.QFileSystemModel):
def columnCount(self, parent = QtCore.QModelIndex()):
return super(YourSystemModel, self).columnCount()+1
def data(self, index, role):
if index.column() == self.columnCount() - 1:
if role == QtCore.Qt.DisplayRole:
return QtCore.QString("YourText")
if role == QtCore.Qt.TextAlignmentRole:
return QtCore.Qt.AlignHCenter
return super(YourSystemModel, self).data(index, role)