Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |
The QStandardItemModel class provides a generic model for storing custom data. More...
#include <QStandardItemModel>
Inherits QAbstractItemModel.
The QStandardItemModel class provides a generic model for storing custom data.
QStandardItemModel provides a model that that can be used as a repository for standard Qt data types. Data is written to the model and read back using the standard QAbstractItemModel interface. The way each item of information is referenced depends on how the data is inserted into the model.
For performance and flexibility, you may want to subclass QAbstractItemModel to provide support for different kinds of repositories. For example, the QDirModel provides a model interface to the underlying file system, and does not actually store file information internally.
An example usage of QStandardItemModel to create a table:
An example usage of QStandardItemModel to create a tree:
QStandardItemModel *model = new QStandardItemModel(); QModelIndex parent; for (int i = 0; i < 4; ++i) { parent = model->index(0, 0, parent); model->insertRows(0, 1, parent); model->insertColumns(0, 1, parent); QModelIndex index = model->index(0, 0, parent); model->setData(index, i); }
See also Model/View Programming, QAbstractItemModel, Simple Tree Model, and example.
Creates an empty model that contains no rows or columns with the given parent.
Creates a model with rows number of rows and columns number of columns.
Destroys the model.
Clears the model, removing all items.
Returns the number of columns in the model that contain items with the given parent.
Reimplemented from QAbstractItemModel.
See also rowCount() and insertColumns().
Returns the data for the given index and role.
Reimplemented from QAbstractItemModel.
See also setData(), setHeaderData(), and index().
Returns the item flags for the given index.
This model returns returns a combination of flags that enables the item (Qt::ItemIsEnabled), allows it to be selected (Qt::ItemIsSelectable) and edited (Qt::ItemIsEditable).
Reimplemented from QAbstractItemModel.
See also Qt::ItemFlags.
Returns true if the parent model index has child items; otherwise returns false.
To add children use insertColumns() and insertRows().
Reimplemented from QAbstractItemModel.
See also rowCount(), columnCount(), and parent().
Returns a model index for the given row, column, and parent.
Reimplemented from QAbstractItemModel.
See also data().
Inserts count columns into the model, creating new items as children of the given parent. The new columns are inserted before the column specified.
If column is 0, the columns are prepended to any existing columns in the parent. If column is columnCount(), the columns are appended to any existing columns in the parent. If parent has no children, a single row with count columns is inserted.
Returns true if the columns were successfully inserted; otherwise returns false.
Reimplemented from QAbstractItemModel.
See also insertColumn(), insertRows(), removeColumns(), and columnCount().
Inserts count rows into the model, creating new items as children of the given parent. The new rows are inserted before the row specified.
If row is 0, the rows are prepended to any existing rows in the parent. If row is rowCount(), the rows are appended to any existing rows in the parent. If parent has no children, a single column with count rows is inserted.
Note that a row with no columns will not show up in the treeview.
Returns true if the rows were successfully inserted; otherwise returns false.
Reimplemented from QAbstractItemModel.
See also insertRow(), insertColumns(), removeRows(), and rowCount().
Returns a model index for the parent of the child item.
Reimplemented from QAbstractItemModel.
See also hasChildren().
Removes count columns from the model, starting with the given column. The items removed are children of the item represented by the parent model index.
Returns true if the columns were successfully removed; otherwise returns false.
Reimplemented from QAbstractItemModel.
See also insertColumns() and columnCount().
Removes count rows from the model, starting with the given row. The items removed are children of the item represented by the parent model index.
Returns true if the rows were successfully removed; otherwise returns false.
Reimplemented from QAbstractItemModel.
See also insertRows(), removeColumns(), and rowCount().
Returns the number of rows in the model that contain items with the given parent.
Reimplemented from QAbstractItemModel.
See also columnCount() and insertRows().
Sets the data for the given index and role to the value specified.
Returns false if index isn't valid.
Reimplemented from QAbstractItemModel.
See also Qt::ItemDataRole, data(), itemData(), and setHeaderData().
Copyright © 2005 Trolltech | Trademarks | Qt 4.1.0 |