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

Form view


The form view is useful when you want to traverse the records one by one and perform some modifications to it. In this section, we will look at how to create a dialog form that displays, and we will also learn about how to add, edit, and delete records using the form dialog. We will use the same employee table that was created in our previous example.

We will not discuss the layout that is used in this program as our main aim is to discuss the form view. The model is created using the QSqlTableModel, setting the sort factor with the first_name column in the ascending order:

self.model = QSqlTableModel(self)
        self.model.setTable("employee")
        self.model.setSort(FIRST_NAME, Qt.AscendingOrder)
        self.model.select()

Next, we set the mapping of the form values with the column using the QDataWidgetMapper class. This class is used to provide mapping between a section of a data model to widgets. The addMapping(widget, section) function maps the widget to the section from...

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 R$50/month. Cancel anytime