How to replace rows with columns in QSqlTableModel?

青春壹個敷衍的年華 提交于 2019-12-25 08:18:59

问题


I found a lot of answers how to transform rows into columns in SQL. But I need to transforms rows into columns in QSqlTableModel. As I understand it should not be a very difficult task but I can't find any idea of how to realize it. Perhaps data(), setData() and some other methods could be reimplemented, but I am afraid to miss something...

Or, maybe, some methods of QTableView should be reimplemented.


回答1:


As I understand QIdentityProxyModel could be used to solve this problem. Unfortunately, QIdentityProxyModel is available since version 4.8.

So I inherited QAbstractProxyModel and implemented mapToSource() and mapFromSource(), rowCount(), columnCount() and few more methods to switch rows with columns.



来源:https://stackoverflow.com/questions/9668422/how-to-replace-rows-with-columns-in-qsqltablemodel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!