QT_GUI_IM_6_1 - 8BitsCoding/RobotMentor GitHub Wiki

  • Seperation of data and its presentation into separate components
  • Models, views, and delegates communicate with each other using signals and slots:
  • Signals from the model inform the view about changes to the data held by the data source.
  • Signals from the view provide information about the user's interaction with the items being displayed.
  • Signals from the delegate are used during editing to tell the model and view about the state of the editor.

어쨋든 보여지는 부분과 구현부를 나누겠다는 말이군


Three Convenience View Widgets

  • Data is bundled into the Widget class objects
  • Useful when trying to show a simple data set in widget quickly
  • Not suitable for huge & frequently changing data sets.

Model Classes

  • QAbstractListModel
  • QAbstractTableModel
  • QAbstractItemModel
  • QStringListModel
  • QStandardItemModel
  • QFileSystemModel
  • QSqlQueryModel
  • QSqlTableModel
  • QSqlRelationalTableModel

Views can be connected to different kinds of data sources easily


  • Each item in the data structure has a row and a column it belongs to
  • Each item must also have a parent item
  • The root item is to top level parent in the entire data structure
  • items live in a table like data structure under their assigned parent
  • The list like model data structure is a particular case where root item has one child table with only one columns of data
  • An item is represented by a QModelIndex Class object.

Getting a QModelIndex for an item in the model

Parents, row, and columns

The diagram shows a representation of a tree model in which each item is referred to by a parent, a row number, and column number.

Items "A" anc "C" are represented as top-level siblings in the model:

QModelIndex indexA = model->index(0, 0, QModelIndex());
QModelIndex indexB = model->index(2, 1, QModelIndex());

Item "A" has a number of children.

A model Index for item "B" is obtained with the following code.

QModelIndex indexB = model->index(1, 0, indexA);