Complex data in PyQt models

Heads up! You've already completed this tutorial.

Zoey_Schlemper | 2020-05-07 18:12:18 UTC | #1

Thanks for this awesome tutorial. I have a question about complex data sets. Is it possible for me to use a .json file as my model's data in pyqt views? I have a rather complex data structure. Do I need to simplify it to a basic table?

https://www.pythonguis.com/courses/model-views/modelview-architecture/


martin | 2020-05-10 09:40:45 UTC | #2

Not at all! You can use any data structure you like in your model — just think of the model acting as an interface between how Qt want's to see your data, and how you want to represent it. As long as your model returns data in the format Qt expects it will work fine.

I have more tutorials on this coming shortly (e.g. using pandas datatables, querying databases and displaying complex datatypes).


David_Hansson | 2020-05-18 17:50:32 UTC | #3

More tutorials on using QTableView and how it interact with a QAbstractTableModel would be very usefull. The documentation for this on the internet and in meny of the books is very basic (to basic). And it is very frustrating to check your code for errors since this subject have meny pitfalls. Expanding your QTableView with QSortFilterProxyModell would also be a good follow up on this subject.


The complete guide to packaging Python GUI applications with PyInstaller.
[[ discount.discount_pc ]]% OFF for the next [[ discount.duration ]] [[discount.description ]] with the code [[ discount.coupon_code ]]

Purchasing Power Parity

Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]
Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak

Complex data in PyQt models was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt.