Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Pyside GUI Application Development- Second Edition

You're reading from   Pyside GUI Application Development- Second Edition Develop more dynamic and robust GUI applications using PySide, an open source cross-platform UI framework

Arrow left icon
Product type Paperback
Published in Jan 2016
Publisher Packt
ISBN-13 9781785282454
Length 144 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Venkateshwaran Loganathan Venkateshwaran Loganathan
Author Profile Icon Venkateshwaran Loganathan
Venkateshwaran Loganathan
Gopinath Jaganmohan Gopinath Jaganmohan
Author Profile Icon Gopinath Jaganmohan
Gopinath Jaganmohan
Arrow right icon
View More author details
Toc

Table and form views


This section is devoted to explaining the representation of data in a form view or a table view. But, before that, we can look at some examples of accessing databases through high-level model classes. The following classes are available in Qt for this purpose.

  • QSqlQueryModel: This provides a read-only data model for SQL result sets

  • QSqlTableModel: This provides an editable data model for a single database table

  • QSqlRelationalTableModel: This provides an editable data model for a single database table with foreign key support

Let's view some quick examples of each of these classes.

QSqlQueryModel

This model aims at providing a high-level interface to execute SQL queries and traverse the result set. This class is built on top of the QSqlQuery class and can be used to provide data to view classes, such as QTableView, which we are going to discuss in the forthcoming sections. A sample program using QSqlQueryModel is given as follows:

model = QSqlQueryModel()
model.setQuery(...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime