並べ替えやフィルタリングのために、QSortFilterProxyModelで拡張された関連モデルでテーブルビューを使用しています。行番号(つまり垂直ヘッダー)を除いて、すべて正常に機能します。このコードの使用:
def headerData(self, section, orientation, role):
if role == QtCore.Qt.DisplayRole:
if orientation == QtCore.Qt.Horizontal:
return self.__header[section]
elif orientation == QtCore.Qt.Vertical:
return section + 1
各行には固定行番号が割り当てられています。そして、これはソート/フィルタリング時に問題を引き起こします。私は1つの解決策を考え出しました。デフォルトのフィルタリングと並べ替えの方法をオーバーライドし、いくつかの追加のパラメーター(行番号)をデータに入れて、並べ替えまたはフィルタリングのたびにそれを書き換えます。
質問:これに対する他の解決策はありますか?並べ替え/フィルタリング操作後に実際のアイテムの位置を表示する方法はありますか?