O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Introducing QAbstractItemModel and QAbstractListModel

The first option would be to implement the list with a simple QList of QStrings or QVariants, as we did in Chapter 2, Defining a Solid and Testable App Core. However, Qt provides more powerful data structures that make it easier to implement the model/view paradigm. All these models derive from QAbstractItemModel, provide automatic means of updating the views that rely on them, and can conveniently represent relatively complex data structures, such as trees and tables. A useful starting point for implementing custom data models of a certain complexity is the flexible QStandardItemModel. When the model can be represented as a list, QAbstractListModel (http://doc.qt.io/qt-5.9/qabstractlistmodel.html ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required