Qt 4.8
|
The QStandardItemModel class provides a generic model for storing custom data. More...
#include <qstandarditemmodel.h>
Signals | |
void | itemChanged (QStandardItem *item) |
Signals inherited from QAbstractItemModel | |
void | columnsAboutToBeInserted (const QModelIndex &parent, int first, int last) |
This signal is emitted just before columns are inserted into the model. More... | |
void | columnsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn) |
This signal is emitted just before columns are moved within the model. More... | |
void | columnsAboutToBeRemoved (const QModelIndex &parent, int first, int last) |
This signal is emitted just before columns are removed from the model. More... | |
void | columnsInserted (const QModelIndex &parent, int first, int last) |
This signal is emitted after columns have been inserted into the model. More... | |
void | columnsMoved (const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column) |
This signal is emitted after columns have been moved within the model. More... | |
void | columnsRemoved (const QModelIndex &parent, int first, int last) |
This signal is emitted after columns have been removed from the model. More... | |
void | dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight) |
This signal is emitted whenever the data in an existing item changes. More... | |
void | headerDataChanged (Qt::Orientation orientation, int first, int last) |
This signal is emitted whenever a header is changed. More... | |
void | layoutAboutToBeChanged () |
This signal is emitted just before the layout of a model is changed. More... | |
void | layoutChanged () |
This signal is emitted whenever the layout of items exposed by the model has changed; for example, when the model has been sorted. More... | |
void | modelAboutToBeReset () |
This signal is emitted when reset() is called, before the model's internal state (e. More... | |
void | modelReset () |
This signal is emitted when reset() is called, after the model's internal state (e. More... | |
void | rowsAboutToBeInserted (const QModelIndex &parent, int first, int last) |
This signal is emitted just before rows are inserted into the model. More... | |
void | rowsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow) |
This signal is emitted just before rows are moved within the model. More... | |
void | rowsAboutToBeRemoved (const QModelIndex &parent, int first, int last) |
This signal is emitted just before rows are removed from the model. More... | |
void | rowsInserted (const QModelIndex &parent, int first, int last) |
This signal is emitted after rows have been inserted into the model. More... | |
void | rowsMoved (const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row) |
This signal is emitted after rows have been moved within the model. More... | |
void | rowsRemoved (const QModelIndex &parent, int first, int last) |
This signal is emitted after rows have been removed from the model. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Public Functions | |
void | appendColumn (const QList< QStandardItem *> &items) |
Appends a column containing items. More... | |
void | appendRow (const QList< QStandardItem *> &items) |
Appends a row containing items. More... | |
void | appendRow (QStandardItem *item) |
void | clear () |
Removes all items (including header items) from the model and sets the number of rows and columns to zero. More... | |
int | columnCount (const QModelIndex &parent=QModelIndex()) const |
Reimplemented Function More... | |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const |
Reimplemented Function More... | |
bool | dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) |
Reimplemented Function More... | |
QList< QStandardItem * > | findItems (const QString &text, Qt::MatchFlags flags=Qt::MatchExactly, int column=0) const |
Returns a list of items that match the given text, using the given flags, in the given column. More... | |
Qt::ItemFlags | flags (const QModelIndex &index) const |
Reimplemented Function More... | |
bool | hasChildren (const QModelIndex &parent=QModelIndex()) const |
Reimplemented Function More... | |
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const |
Reimplemented Function More... | |
QStandardItem * | horizontalHeaderItem (int column) const |
Returns the horizontal header item for column if one has been set; otherwise returns 0. More... | |
QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const |
Reimplemented Function More... | |
QModelIndex | indexFromItem (const QStandardItem *item) const |
Returns the QModelIndex associated with the given item. More... | |
void | insertColumn (int column, const QList< QStandardItem *> &items) |
Inserts a column at column containing items. More... | |
bool | insertColumn (int column, const QModelIndex &parent=QModelIndex()) |
Inserts a single column before the given column in the child items of the parent specified. More... | |
bool | insertColumns (int column, int count, const QModelIndex &parent=QModelIndex()) |
Reimplemented Function More... | |
void | insertRow (int row, const QList< QStandardItem *> &items) |
Inserts a row at row containing items. More... | |
void | insertRow (int row, QStandardItem *item) |
bool | insertRow (int row, const QModelIndex &parent=QModelIndex()) |
Inserts a single row before the given row in the child items of the parent specified. More... | |
bool | insertRows (int row, int count, const QModelIndex &parent=QModelIndex()) |
Reimplemented Function More... | |
QStandardItem * | invisibleRootItem () const |
Returns the model's invisible root item. More... | |
QStandardItem * | item (int row, int column=0) const |
Returns the item for the given row and column if one has been set; otherwise returns 0. More... | |
QMap< int, QVariant > | itemData (const QModelIndex &index) const |
Reimplemented Function More... | |
QStandardItem * | itemFromIndex (const QModelIndex &index) const |
Returns a pointer to the QStandardItem associated with the given index. More... | |
const QStandardItem * | itemPrototype () const |
Returns the item prototype used by the model. More... | |
QMimeData * | mimeData (const QModelIndexList &indexes) const |
Reimplemented Function More... | |
QStringList | mimeTypes () const |
Reimplemented Function More... | |
QModelIndex | parent (const QModelIndex &child) const |
Reimplemented Function More... | |
QStandardItemModel (QObject *parent=0) | |
Constructs a new item model with the given parent. More... | |
QStandardItemModel (int rows, int columns, QObject *parent=0) | |
Constructs a new item model that initially has rows rows and columns columns, and that has the given parent. More... | |
bool | removeColumns (int column, int count, const QModelIndex &parent=QModelIndex()) |
Reimplemented Function More... | |
bool | removeRows (int row, int count, const QModelIndex &parent=QModelIndex()) |
Reimplemented Function More... | |
int | rowCount (const QModelIndex &parent=QModelIndex()) const |
Reimplemented Function More... | |
void | setColumnCount (int columns) |
Sets the number of columns in this model to columns. More... | |
bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) |
Reimplemented Function More... | |
bool | setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole) |
Reimplemented Function More... | |
void | setHorizontalHeaderItem (int column, QStandardItem *item) |
Sets the horizontal header item for column to item. More... | |
void | setHorizontalHeaderLabels (const QStringList &labels) |
Sets the horizontal header labels using labels. More... | |
void | setItem (int row, int column, QStandardItem *item) |
Sets the item for the given row and column to item. More... | |
void | setItem (int row, QStandardItem *item) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
bool | setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles) |
Reimplemented Function More... | |
void | setItemPrototype (const QStandardItem *item) |
Sets the item prototype for the model to the specified item. More... | |
void | setRowCount (int rows) |
Sets the number of rows in this model to rows. More... | |
void | setSortRole (int role) |
void | setVerticalHeaderItem (int row, QStandardItem *item) |
Sets the vertical header item for row to item. More... | |
void | setVerticalHeaderLabels (const QStringList &labels) |
Sets the vertical header labels using labels. More... | |
void | sort (int column, Qt::SortOrder order=Qt::AscendingOrder) |
Reimplemented Function More... | |
int | sortRole () const |
Qt::DropActions | supportedDropActions () const |
QStandardItemModel supports both copy and move. More... | |
QList< QStandardItem * > | takeColumn (int column) |
Removes the given column without deleting the column items, and returns a list of pointers to the removed items. More... | |
QStandardItem * | takeHorizontalHeaderItem (int column) |
Removes the horizontal header item at column from the header without deleting it, and returns a pointer to the item. More... | |
QStandardItem * | takeItem (int row, int column=0) |
Removes the item at (row, column) without deleting it. More... | |
QList< QStandardItem * > | takeRow (int row) |
Removes the given row without deleting the row items, and returns a list of pointers to the removed items. More... | |
QStandardItem * | takeVerticalHeaderItem (int row) |
Removes the vertical header item at row from the header without deleting it, and returns a pointer to the item. More... | |
QStandardItem * | verticalHeaderItem (int row) const |
Returns the vertical header item for row row if one has been set; otherwise returns 0. More... | |
~QStandardItemModel () | |
Destructs the model. More... | |
Public Functions inherited from QAbstractItemModel | |
virtual QModelIndex | buddy (const QModelIndex &index) const |
Returns a model index for the buddy of the item represented by index. More... | |
virtual bool | canFetchMore (const QModelIndex &parent) const |
Returns true if there is more data available for parent; otherwise returns false. More... | |
virtual void | fetchMore (const QModelIndex &parent) |
Fetches any available data for the items with the parent specified by the parent index. More... | |
bool | hasIndex (int row, int column, const QModelIndex &parent=QModelIndex()) const |
Returns true if the model returns a valid QModelIndex for row and column with parent, otherwise returns false. More... | |
bool | insertColumn (int column, const QModelIndex &parent=QModelIndex()) |
Inserts a single column before the given column in the child items of the parent specified. More... | |
bool | insertRow (int row, const QModelIndex &parent=QModelIndex()) |
Inserts a single row before the given row in the child items of the parent specified. More... | |
virtual QModelIndexList | match (const QModelIndex &start, int role, const QVariant &value, int hits=1, Qt::MatchFlags flags=Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const |
Returns a list of indexes for the items in the column of the start index where data stored under the given role matches the specified value. More... | |
QAbstractItemModel (QObject *parent=0) | |
Constructs an abstract item model with the given parent. More... | |
bool | removeColumn (int column, const QModelIndex &parent=QModelIndex()) |
Removes the given column from the child items of the parent specified. More... | |
bool | removeRow (int row, const QModelIndex &parent=QModelIndex()) |
Removes the given row from the child items of the parent specified. More... | |
const QHash< int, QByteArray > & | roleNames () const |
Returns the model's role names. More... | |
void | setSupportedDragActions (Qt::DropActions) |
Sets the supported drag actions for the items in the model. More... | |
QModelIndex | sibling (int row, int column, const QModelIndex &idx) const |
Returns the sibling at row and column for the item at index, or an invalid QModelIndex if there is no sibling at that location. More... | |
virtual QSize | span (const QModelIndex &index) const |
Returns the row and column span of the item represented by index. More... | |
Qt::DropActions | supportedDragActions () const |
Returns the actions supported by the data in this model. More... | |
virtual | ~QAbstractItemModel () |
Destroys the abstract item model. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
virtual bool | event (QEvent *) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Filters events if this object has been installed as an event filter for the watched object. More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Protected Functions | |
QStandardItemModel (QStandardItemModelPrivate &dd, QObject *parent=0) | |
Protected Functions inherited from QAbstractItemModel | |
void | beginInsertColumns (const QModelIndex &parent, int first, int last) |
Begins a column insertion operation. More... | |
void | beginInsertRows (const QModelIndex &parent, int first, int last) |
Begins a row insertion operation. More... | |
bool | beginMoveColumns (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationColumn) |
Begins a column move operation. More... | |
bool | beginMoveRows (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationRow) |
Begins a row move operation. More... | |
void | beginRemoveColumns (const QModelIndex &parent, int first, int last) |
Begins a column removal operation. More... | |
void | beginRemoveRows (const QModelIndex &parent, int first, int last) |
Begins a row removal operation. More... | |
void | beginResetModel () |
Begins a model reset operation. More... | |
void | changePersistentIndex (const QModelIndex &from, const QModelIndex &to) |
Changes the QPersistentModelIndex that is equal to the given from model index to the given to model index. More... | |
void | changePersistentIndexList (const QModelIndexList &from, const QModelIndexList &to) |
Changes the QPersistentModelIndexes that is equal to the indexes in the given from model index list to the given to model index list. More... | |
QModelIndex | createIndex (int row, int column, void *data=0) const |
Creates a model index for the given row and column with the internal pointer ptr. More... | |
QModelIndex | createIndex (int row, int column, int id) const |
Use QModelIndex QAbstractItemModel::createIndex(int row, int column, quint32 id) instead. More... | |
QModelIndex | createIndex (int row, int column, quint32 id) const |
Creates a model index for the given row and column with the internal identifier, id. More... | |
bool | decodeData (int row, int column, const QModelIndex &parent, QDataStream &stream) |
void | encodeData (const QModelIndexList &indexes, QDataStream &stream) const |
void | endInsertColumns () |
Ends a column insertion operation. More... | |
void | endInsertRows () |
Ends a row insertion operation. More... | |
void | endMoveColumns () |
Ends a column move operation. More... | |
void | endMoveRows () |
Ends a row move operation. More... | |
void | endRemoveColumns () |
Ends a column removal operation. More... | |
void | endRemoveRows () |
Ends a row removal operation. More... | |
void | endResetModel () |
Completes a model reset operation. More... | |
QModelIndexList | persistentIndexList () const |
Returns the list of indexes stored as persistent indexes in the model. More... | |
QAbstractItemModel (QAbstractItemModelPrivate &dd, QObject *parent=0) | |
void | reset () |
Resets the model to its original state in any attached views. More... | |
void | setRoleNames (const QHash< int, QByteArray > &roleNames) |
Sets the model's role names to roleNames. More... | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More... | |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *) |
This event handler can be reimplemented in a subclass to receive timer events for the object. More... | |
Properties | |
int | sortRole |
the item role that is used to query the model's data when sorting items More... | |
Friends | |
class | QStandardItem |
class | QStandardItemPrivate |
Additional Inherited Members | |
Public Slots inherited from QAbstractItemModel | |
virtual void | revert () |
Lets the model know that it should discard cached information. More... | |
virtual bool | submit () |
Lets the model know that it should submit cached information to permanent storage. More... | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Slots inherited from QAbstractItemModel | |
void | resetInternalData () |
This slot is called just after the internal data of a model is cleared while it is being reset. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
The QStandardItemModel class provides a generic model for storing custom data.
QStandardItemModel can be used as a repository for standard Qt data types. It is one of the Model/View Classes and is part of Qt's Model/View Programming framework.
QStandardItemModel provides a classic item-based approach to working with the model. The items in a QStandardItemModel are provided by QStandardItem.
QStandardItemModel implements the QAbstractItemModel interface, which means that the model can be used to provide data in any view that supports that interface (such as QListView, QTableView and QTreeView, and your own custom views). For performance and flexibility, you may want to subclass QAbstractItemModel to provide support for different kinds of data repositories. For example, the QDirModel provides a model interface to the underlying file system.
When you want a list or tree, you typically create an empty QStandardItemModel and use appendRow() to add items to the model, and item() to access an item. If your model represents a table, you typically pass the dimensions of the table to the QStandardItemModel constructor and use setItem() to position items into the table. You can also use setRowCount() and setColumnCount() to alter the dimensions of the model. To insert items, use insertRow() or insertColumn(), and to remove items, use removeRow() or removeColumn().
You can set the header labels of your model with setHorizontalHeaderLabels() and setVerticalHeaderLabels().
You can search for items in the model with findItems(), and sort the model by calling sort().
Call clear() to remove all items from the model.
An example usage of QStandardItemModel to create a table:
An example usage of QStandardItemModel to create a tree:
After setting the model on a view, you typically want to react to user actions, such as an item being clicked. Since a QAbstractItemView provides QModelIndex-based signals and functions, you need a way to obtain the QStandardItem that corresponds to a given QModelIndex, and vice versa. itemFromIndex() and indexFromItem() provide this mapping. Typical usage of itemFromIndex() includes obtaining the item at the current index in a view, and obtaining the item that corresponds to an index carried by a QAbstractItemView signal, such as QAbstractItemView::clicked(). First you connect the view's signal to a slot in your class:
When you receive the signal, you call itemFromIndex() on the given model index to get a pointer to the item:
Conversely, you must obtain the QModelIndex of an item when you want to invoke a model/view function that takes an index as argument. You can obtain the index either by using the model's indexFromItem() function, or, equivalently, by calling QStandardItem::index():
You are, of course, not required to use the item-based approach; you could instead rely entirely on the QAbstractItemModel interface when working with the model, or use a combination of the two as appropriate.
Definition at line 318 of file qstandarditemmodel.h.
|
explicit |
Constructs a new item model with the given parent.
Definition at line 2162 of file qstandarditemmodel.cpp.
QStandardItemModel::QStandardItemModel | ( | int | rows, |
int | columns, | ||
QObject * | parent = 0 |
||
) |
Constructs a new item model that initially has rows rows and columns columns, and that has the given parent.
Definition at line 2174 of file qstandarditemmodel.cpp.
QStandardItemModel::~QStandardItemModel | ( | ) |
Destructs the model.
The model destroys all its items.
Definition at line 2199 of file qstandarditemmodel.cpp.
|
protected |
Definition at line 2189 of file qstandarditemmodel.cpp.
void QStandardItemModel::appendColumn | ( | const QList< QStandardItem *> & | items | ) |
Appends a column containing items.
If necessary, the row count is increased to the size of items.
Definition at line 2651 of file qstandarditemmodel.cpp.
void QStandardItemModel::appendRow | ( | const QList< QStandardItem *> & | items | ) |
Appends a row containing items.
If necessary, the column count is increased to the size of items.
Definition at line 2635 of file qstandarditemmodel.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
When building a list or a tree that has only one column, this function provides a convenient way to append a single new item.
Definition at line 434 of file qstandarditemmodel.h.
void QStandardItemModel::clear | ( | ) |
Removes all items (including header items) from the model and sets the number of rows and columns to zero.
Definition at line 2209 of file qstandarditemmodel.cpp.
Referenced by QUrlModel::setFileSystemModel().
|
virtual |
Reimplemented Function
Implements QAbstractItemModel.
Definition at line 2841 of file qstandarditemmodel.cpp.
Referenced by dropMimeData(), headerData(), horizontalHeaderItem(), setHeaderData(), setHorizontalHeaderItem(), setHorizontalHeaderLabels(), and takeHorizontalHeaderItem().
|
virtual |
Reimplemented Function
Implements QAbstractItemModel.
Definition at line 2851 of file qstandarditemmodel.cpp.
Referenced by QUrlModel::addUrls(), QUrlModel::mimeData(), mimeData(), and QUrlModel::urls().
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 3199 of file qstandarditemmodel.cpp.
QList< QStandardItem * > QStandardItemModel::findItems | ( | const QString & | text, |
Qt::MatchFlags | flags = Qt::MatchExactly , |
||
int | column = 0 |
||
) | const |
Returns a list of items that match the given text, using the given flags, in the given column.
Definition at line 2613 of file qstandarditemmodel.cpp.
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 2861 of file qstandarditemmodel.cpp.
Referenced by QUrlModel::flags(), and QFileDialogComboBox::showPopup().
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 2879 of file qstandarditemmodel.cpp.
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 2889 of file qstandarditemmodel.cpp.
QStandardItem * QStandardItemModel::horizontalHeaderItem | ( | int | column | ) | const |
Returns the horizontal header item for column if one has been set; otherwise returns 0.
Definition at line 2437 of file qstandarditemmodel.cpp.
Referenced by setHorizontalHeaderLabels().
|
virtual |
Reimplemented Function
Implements QAbstractItemModel.
Definition at line 2922 of file qstandarditemmodel.cpp.
Referenced by QUrlModel::addUrls(), QUrlModel::changed(), QUrlModel::dataChanged(), dropMimeData(), findItems(), and QUrlModel::urls().
QModelIndex QStandardItemModel::indexFromItem | ( | const QStandardItem * | item | ) | const |
Returns the QModelIndex associated with the given item.
Use this function when you want to perform an operation that requires the QModelIndex of the item, such as QAbstractItemView::scrollTo(). QStandardItem::index() is provided as convenience; it is equivalent to calling this function.
Definition at line 2275 of file qstandarditemmodel.cpp.
Referenced by parent(), and QStandardItemPrivate::setModel().
void QStandardItemModel::insertColumn | ( | int | column, |
const QList< QStandardItem *> & | items | ||
) |
Inserts a column at column containing items.
If necessary, the row count is increased to the size of items.
Definition at line 2704 of file qstandarditemmodel.cpp.
|
inline |
Inserts a single column before the given column in the child items of the parent specified.
Returns true if the column is inserted; otherwise returns false.
Definition at line 442 of file qstandarditemmodel.h.
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 2939 of file qstandarditemmodel.cpp.
Referenced by dropMimeData(), and QUrlModel::setFileSystemModel().
void QStandardItemModel::insertRow | ( | int | row, |
const QList< QStandardItem *> & | items | ||
) |
Inserts a row at row containing items.
If necessary, the column count is increased to the size of items.
Definition at line 2676 of file qstandarditemmodel.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Inserts a row at row containing item.
When building a list or a tree that has only one column, this function provides a convenient way to append a single new item.
Definition at line 437 of file qstandarditemmodel.h.
|
inline |
Inserts a single row before the given row in the child items of the parent specified.
Returns true if the row is inserted; otherwise returns false.
Definition at line 440 of file qstandarditemmodel.h.
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 2951 of file qstandarditemmodel.cpp.
Referenced by QUrlModel::addUrls(), and dropMimeData().
QStandardItem * QStandardItemModel::invisibleRootItem | ( | ) | const |
Returns the model's invisible root item.
The invisible root item provides access to the model's top-level items through the QStandardItem API, making it possible to write functions that can treat top-level items and their children in a uniform way; for example, recursive functions involving a tree model.
Definition at line 2377 of file qstandarditemmodel.cpp.
Referenced by appendColumn(), appendRow(), dropMimeData(), insertColumn(), and insertRow().
QStandardItem * QStandardItemModel::item | ( | int | row, |
int | column = 0 |
||
) | const |
Returns the item for the given row and column if one has been set; otherwise returns 0.
Definition at line 2355 of file qstandarditemmodel.cpp.
Referenced by columnCount(), data(), QStandardItemModelPrivate::decodeDataRecursive(), dropMimeData(), flags(), hasChildren(), insertColumns(), insertRows(), itemData(), itemFromIndex(), mimeData(), removeColumns(), removeRows(), rowCount(), setData(), setHorizontalHeaderLabels(), setItemData(), setItemPrototype(), setVerticalHeaderLabels(), and QFileDialogComboBox::showPopup().
|
signal |
This signal is emitted whenever the data of item has changed.
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 2963 of file qstandarditemmodel.cpp.
QStandardItem * QStandardItemModel::itemFromIndex | ( | const QModelIndex & | index | ) | const |
Returns a pointer to the QStandardItem associated with the given index.
Calling this function is typically the initial step when processing QModelIndex-based signals from a view, such as QAbstractItemView::activated(). In your slot, you call itemFromIndex(), with the QModelIndex carried by the signal as argument, to obtain a pointer to the corresponding QStandardItem.
Note that this function will lazily create an item for the index (using itemPrototype()), and set it in the parent item's child table, if no item already exists at that index.
If index is an invalid index, this function returns 0.
Definition at line 2243 of file qstandarditemmodel.cpp.
Referenced by dropMimeData(), findItems(), insertColumns(), insertRows(), mimeData(), setData(), and setItemData().
const QStandardItem * QStandardItemModel::itemPrototype | ( | ) | const |
Returns the item prototype used by the model.
The model uses the item prototype as an item factory when it needs to construct new items on demand (for instance, when a view or item delegate calls setData()).
Definition at line 2598 of file qstandarditemmodel.cpp.
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 3104 of file qstandarditemmodel.cpp.
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 3096 of file qstandarditemmodel.cpp.
Referenced by mimeData().
|
virtual |
Reimplemented Function
Implements QAbstractItemModel.
Definition at line 2973 of file qstandarditemmodel.cpp.
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 2985 of file qstandarditemmodel.cpp.
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 2998 of file qstandarditemmodel.cpp.
Referenced by QUrlModel::setUrls().
|
virtual |
Reimplemented Function
Implements QAbstractItemModel.
Definition at line 3011 of file qstandarditemmodel.cpp.
Referenced by QUrlModel::addUrls(), QUrlModel::changed(), dropMimeData(), headerData(), setHeaderData(), QUrlModel::setUrls(), setVerticalHeaderItem(), setVerticalHeaderLabels(), takeVerticalHeaderItem(), QUrlModel::urls(), and verticalHeaderItem().
void QStandardItemModel::setColumnCount | ( | int | columns | ) |
Sets the number of columns in this model to columns.
If this is less than columnCount(), the data in the unwanted columns is discarded.
Definition at line 2314 of file qstandarditemmodel.cpp.
Referenced by setHorizontalHeaderItem(), and setHorizontalHeaderLabels().
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 3021 of file qstandarditemmodel.cpp.
Referenced by QUrlModel::setData().
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 3035 of file qstandarditemmodel.cpp.
void QStandardItemModel::setHorizontalHeaderItem | ( | int | column, |
QStandardItem * | item | ||
) |
Sets the horizontal header item for column to item.
The model takes ownership of the item. If necessary, the column count is increased to fit the item. The previous header item (if there was one) is deleted.
Definition at line 2396 of file qstandarditemmodel.cpp.
Referenced by setHorizontalHeaderLabels().
void QStandardItemModel::setHorizontalHeaderLabels | ( | const QStringList & | labels | ) |
Sets the horizontal header labels using labels.
If necessary, the column count is increased to the size of labels.
Definition at line 2518 of file qstandarditemmodel.cpp.
void QStandardItemModel::setItem | ( | int | row, |
int | column, | ||
QStandardItem * | item | ||
) |
Sets the item for the given row and column to item.
The model takes ownership of the item. If necessary, the row count and column count are increased to fit the item. The previous item at the given location (if there was one) is deleted.
Definition at line 2333 of file qstandarditemmodel.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 431 of file qstandarditemmodel.h.
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 3069 of file qstandarditemmodel.cpp.
void QStandardItemModel::setItemPrototype | ( | const QStandardItem * | item | ) |
Sets the item prototype for the model to the specified item.
The model takes ownership of the prototype.
The item prototype acts as a QStandardItem factory, by relying on the QStandardItem::clone() function. To provide your own prototype, subclass QStandardItem, reimplement QStandardItem::clone() and set the prototype to be an instance of your custom class. Whenever QStandardItemModel needs to create an item on demand (for instance, when a view or item delegate calls setData())), the new items will be instances of your custom class.
Definition at line 2577 of file qstandarditemmodel.cpp.
void QStandardItemModel::setRowCount | ( | int | rows | ) |
Sets the number of rows in this model to rows.
If this is less than rowCount(), the data in the unwanted rows is discarded.
Definition at line 2296 of file qstandarditemmodel.cpp.
Referenced by setVerticalHeaderItem(), and setVerticalHeaderLabels().
void QStandardItemModel::setSortRole | ( | int | role | ) |
Definition at line 2832 of file qstandarditemmodel.cpp.
void QStandardItemModel::setVerticalHeaderItem | ( | int | row, |
QStandardItem * | item | ||
) |
Sets the vertical header item for row to item.
The model takes ownership of the item. If necessary, the row count is increased to fit the item. The previous header item (if there was one) is deleted.
Definition at line 2458 of file qstandarditemmodel.cpp.
Referenced by setVerticalHeaderLabels().
void QStandardItemModel::setVerticalHeaderLabels | ( | const QStringList & | labels | ) |
Sets the vertical header labels using labels.
If necessary, the row count is increased to the size of labels.
Definition at line 2544 of file qstandarditemmodel.cpp.
|
virtual |
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 3081 of file qstandarditemmodel.cpp.
int QStandardItemModel::sortRole | ( | ) | const |
Referenced by takeVerticalHeaderItem().
|
virtual |
QStandardItemModel supports both copy and move.
Reimplemented Function
Reimplemented from QAbstractItemModel.
Definition at line 2914 of file qstandarditemmodel.cpp.
QList< QStandardItem * > QStandardItemModel::takeColumn | ( | int | column | ) |
Removes the given column without deleting the column items, and returns a list of pointers to the removed items.
The model releases ownership of the items. For items in the column that have not been set, the corresponding pointers in the list will be 0.
Definition at line 2758 of file qstandarditemmodel.cpp.
QStandardItem * QStandardItemModel::takeHorizontalHeaderItem | ( | int | column | ) |
Removes the horizontal header item at column from the header without deleting it, and returns a pointer to the item.
The model releases ownership of the item.
Definition at line 2776 of file qstandarditemmodel.cpp.
QStandardItem * QStandardItemModel::takeItem | ( | int | row, |
int | column = 0 |
||
) |
Removes the item at (row, column) without deleting it.
The model releases ownership of the item.
Definition at line 2720 of file qstandarditemmodel.cpp.
QList< QStandardItem * > QStandardItemModel::takeRow | ( | int | row | ) |
Removes the given row without deleting the row items, and returns a list of pointers to the removed items.
The model releases ownership of the items. For items in the row that have not been set, the corresponding pointers in the list will be 0.
Definition at line 2739 of file qstandarditemmodel.cpp.
QStandardItem * QStandardItemModel::takeVerticalHeaderItem | ( | int | row | ) |
Removes the vertical header item at row from the header without deleting it, and returns a pointer to the item.
The model releases ownership of the item.
Definition at line 2801 of file qstandarditemmodel.cpp.
QStandardItem * QStandardItemModel::verticalHeaderItem | ( | int | row | ) | const |
Returns the vertical header item for row row if one has been set; otherwise returns 0.
Definition at line 2499 of file qstandarditemmodel.cpp.
Referenced by setVerticalHeaderLabels().
|
friend |
Definition at line 423 of file qstandarditemmodel.h.
|
friend |
Definition at line 422 of file qstandarditemmodel.h.
|
private |
the item role that is used to query the model's data when sorting items
The default value is Qt::DisplayRole.
Definition at line 321 of file qstandarditemmodel.h.
Referenced by QStandardItem::operator<().