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
Qt5 C++ GUI Programming Cookbook

You're reading from   Qt5 C++ GUI Programming Cookbook Design and build a functional, appealing, and user-friendly graphical user interface

Arrow left icon
Product type Paperback
Published in Jul 2016
Publisher Packt
ISBN-13 9781783280278
Length 300 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Lee Zhi Eng Lee Zhi Eng
Author Profile Icon Lee Zhi Eng
Lee Zhi Eng
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Look and Feel Customization FREE CHAPTER 2. States and Animations 3. QPainter and 2D Graphics 4. OpenGL Implementation 5. Building a Touch Screen Application with Qt5 6. XML Parsing Made Easy 7. Conversion Library 8. Accessing Databases 9. Developing a Web Application Using Qt Web Engine Index

Displaying information from a database on a model view


In this recipe, we will learn how to display multiple sets of data obtained from our SQL database on a model view in our program.

How to do it…

Follow these steps to display information from a database on a model view widget:

  1. We will be using the database table called employee, which we used in the previous example. This time, we need a lot more data in the employee table. Open up your web browser and log in to your phpMyAdmin control panel. Add data for a few more employees so that we can display it later in our program:

  2. After that, open up Qt Creator, create a new Qt Widgets Application project, and then add the SQL module to your project.

  3. Next, open up mainwindow.ui and add a table widget (not table view) from Item Widget (Item-Based) under the Widget box pane. Select the main window on the canvas and click on either the Layout Vertically or Layout Horizontally button to make the table widget stick to the size of the main window, even...

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