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

Create GUI Applications with Python & Qt5 by Martin Fitzpatrick — (PyQt5 Edition) The hands-on guide to making apps with Python — Over 15,000 copies sold!

More info Get the book

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.

1:1 Coaching & Tutoring for your Python GUIs project
Martin Fitzpatrick Python GUIs Coaching & Training
60 mins ($195) Book Now

1:1 Python GUIs Coaching & Training

Comprehensive code reviewBugfixes & improvements • Maintainability advice and architecture improvements • Design and usability assessment • Suggestions and tips to expand your knowledgePackaging and distribution help for Windows, Mac & Linux • Find out more.


Bring Your PyQt/PySide Application to Market — Stuck in development hell? I'll help you get your project focused, finished and released. Benefit from years of practical experience releasing software with Python.

Find out More

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak
Martin Fitzpatrick

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. Martin founded PythonGUIs to provide easy to follow GUI programming tutorials to the Python community. He has written a number of popular Python books on the subject.