0

Ok - taking baby steps toward a very simple MVC app using pyside and sqlalchemy... such baby steps that I've got stuck on step #1!

I want to populate a QTableView with data. Should I be using QSqlTableModel or QStandardItemModel or QAbstractItemModel... or something else. If using QSqlTableModel, can I just 'setTable' (and, if so, how).

If anybody can point me in the direction of a decent tutorial or good qt/sqlalchemy example I would be eternally grateful.

I understand that this may be a bit basic.

Steven Lee
  • 179
  • 2
  • 14

2 Answers2

0

I'd suggest you start with a list to understand how the model-view implementation actually works first. Inherit your custom model from QAbstractListModel and you just need to implement the methods data and rowCount for it to work.

Here is a good tutorial explaining everything https://www.pythonguis.com/tutorials/modelview-architecture/

And if you want something for reference, I've found this really old gist implementing an sqlalchemy model for a tableview. It's on pyqt4 and possible would not work anymore but it should help guide you in the right direction. https://gist.github.com/harvimt/4699169

Gustavo J.C.
  • 316
  • 4
  • 8
-1

I suggest to take a look for Camelot project.

http://www.python-camelot.com/index.html

Maybe you can get some ideas from there.

DamnWidget
  • 1,397
  • 2
  • 10
  • 16