Qt:Документация 4.3.2/qstringlistmodel
Материал из Wiki.crossplatform.ru
Внимание: Актуальная версия перевода документации находится здесь |
__NOTOC__
Главная · Все классы · Основные классы · Классы по группам · Модули · Функции |
QStringListModel Class Reference
[модуль QtGui ]
The QStringListModel class provides a model that supplies strings to views. Далее...
#include <QStringListModel>
Inherits QAbstractListModel.
Открытые функции
- QStringListModel ( QObject * parent = 0 )
- QStringListModel ( const QStringList & strings, QObject * parent = 0 )
- virtual QVariant data ( const QModelIndex & index, int role ) const
- virtual Qt::ItemFlags flags ( const QModelIndex & index ) const
- virtual bool insertRows ( int row, int count, const QModelIndex & parent = QModelIndex() )
- virtual bool removeRows ( int row, int count, const QModelIndex & parent = QModelIndex() )
- virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const
- virtual bool setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole )
- void setStringList ( const QStringList & strings )
- QStringList stringList () const
- 1 public function inherited from QAbstractListModel
- 34 открытых функций, унаследованных от QAbstractItemModel
- 29 открытых функций, унаследованных от QObject
Дополнительные унаследованные члены
- 1 свойство, унаследованное от QObject
- 2 открытых слотов, унаследованных от QAbstractItemModel
- 1 открытый слот, унаследованный от QObject
- 14 сигналов, унаследованных от QAbstractItemModel
- 1 сигнал, унаследованный от QObject
- 5 статических открытых членов, унаследованных от QObject
- 14 защищенных функций, унаследованных от QAbstractItemModel
- 7 защищенных функций, унаследованных от QObject
Подробное описание
The QStringListModel class provides a model that supplies strings to views.
QStringListModel is an editable model that can be used for simple cases where you need to display a number of strings in a view widget, such as a QListView or a QComboBox.
The model provides all the standard functions of an editable model, representing the data in the string list as a model with one column and a number of rows equal to the number of items in the list.
Model indexes corresponding to items are obtained with the index() function, and item flags are obtained with flags(). Item data is read with the data() function and written with setData(). The number of rows (and number of items in the string list) can be found with the rowCount() function.
The model can be constructed with an existing string list, or strings can be set later with the setStringList() convenience function. Strings can also be inserted in the usual way with the insertRows() function, and removed with removeRows(). The contents of the string list can be retrieved with the stringList() convenience function.
An example usage of QStringListModel:
QStringListModel *model = new QStringListModel(); QStringList list; list << "a" << "b" << "c"; model->setStringList(list);
See also QAbstractListModel, QAbstractItemModel, and Model Classes.
Описание функций-членов
QStringListModel::QStringListModel ( QObject * parent = 0 )
Constructs a string list model with the given parent.
QStringListModel::QStringListModel ( const QStringList & strings, QObject * parent = 0 )
Constructs a string list model containing the specified strings with the given parent.
QVariant QStringListModel::data ( const QModelIndex & index, int role ) const [virtual]
Returns data for the specified role, from the item with the given index.
If the view requests an invalid index, an invalid variant is returned.
Переопределено из QAbstractItemModel.
Смотрите также setData().
Qt::ItemFlags QStringListModel::flags ( const QModelIndex & index ) const [virtual]
Returns the flags for the item with the given index.
Valid items are enabled, selectable, and editable.
Переопределено из QAbstractItemModel.
See also QAbstractItemModel::flags().
bool QStringListModel::insertRows ( int row, int count, const QModelIndex & parent = QModelIndex() ) [virtual]
Inserts count rows into the model, beginning at the given row.
The parent index of the rows is optional and is only used for consistency with QAbstractItemModel. By default, a null index is specified, indicating that the rows are inserted in the top level of the model.
Переопределено из QAbstractItemModel.
See also QAbstractItemModel::insertRows().
bool QStringListModel::removeRows ( int row, int count, const QModelIndex & parent = QModelIndex() ) [virtual]
Removes count rows from the model, beginning at the given row.
The parent index of the rows is optional and is only used for consistency with QAbstractItemModel. By default, a null index is specified, indicating that the rows are removed in the top level of the model.
Переопределено из QAbstractItemModel.
See also QAbstractItemModel::removeRows().
int QStringListModel::rowCount ( const QModelIndex & parent = QModelIndex() ) const [virtual]
Returns the number of rows in the model. This value corresponds to the number of items in the model's internal string list.
The optional parent argument is in most models used to specify the parent of the rows to be counted. Because this is a list if a valid parent is specified, the result will always be 0.
Переопределено из QAbstractItemModel.
See also insertRows(), removeRows(), and QAbstractItemModel::rowCount().
bool QStringListModel::setData ( const QModelIndex & index, const QVariant & value, int role = Qt::EditRole ) [virtual]
Sets the data for the specified role in the item with the given index in the model, to the provided value.
The dataChanged() signal is emitted if the item is changed.
Переопределено из QAbstractItemModel.
See also Qt::ItemDataRole and data().
void QStringListModel::setStringList ( const QStringList & strings )
Sets the model's internal string list to strings. The model will notify any attached views that its underlying data has changed.
See also stringList() and dataChanged().
QStringList QStringListModel::stringList () const
Returns the string list used by the model to store data.
See also setStringList().
Copyright © 2007 Trolltech | Trademarks | Qt 4.3.2
|