Hi I am using a QTableView to display data from a sql table using the qsqltablemodel asfollows:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(par
Updated for PyQt5
from PyQt5.QtCore import Qt, QAbstractProxyModel, QModelIndex, QSortFilterProxyModel class HorizontalProxyModel(QAbstractProxyModel): """Rotates model 90 degrees""" def __init__(self, src, parent=None): super(HorizontalProxyModel, self).__init__(parent) self.setSourceModel(src) def mapToSource(self, proxyIndex: QModelIndex) -> QModelIndex: if self.sourceModel(): return self.sourceModel().index(proxyIndex.column(), proxyIndex.row()) else: return QModelIndex() def mapFromSource(self, sourceIndex: QModelIndex) -> QModelIndex: return self.index(sourceIndex.column(), sourceIndex.row()) def index(self, row: int, column: int, parent: QModelIndex = ...) -> QModelIndex: return self.createIndex(row, column) def parent(self, child: QModelIndex) -> QModelIndex: return QModelIndex() def rowCount(self, parent: QModelIndex = ...) -> int: return self.sourceModel().columnCount() if self.sourceModel() else 0 def columnCount(self, parent: QModelIndex = ...) -> int: return self.sourceModel().rowCount() if self.sourceModel() else 0 def headerData(self, section: int, orientation: Qt.Orientation, role: int = ...) -> typing.Any: if not self.sourceModel(): return None new_orientation = Qt.Vertical if orientation == Qt.Horizontal else Qt.Horizontal return self.sourceModel().headerData(section, new_orientation, role)