Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QStringListModel Class

The QStringListModel class provides a model that supplies strings to views. More...

 #include <QStringListModel>

Inherits: QAbstractListModel.

Inherited by: QHelpIndexModel.

Public Functions

QAbstractItemModel(QObject * parent = 0)
QStringListModel(QObject * parent = 0)
QStringListModel(const QStringList & strings, QObject * parent = 0)
virtual ~QAbstractItemModel()
virtual QModelIndex buddy(const QModelIndex & index) const
virtual bool canDropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent) const
virtual bool canFetchMore(const QModelIndex & parent) const
virtual int columnCount(const QModelIndex & parent = QModelIndex()) const = 0
virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const = 0
virtual bool dropMimeData(const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent)
virtual void fetchMore(const QModelIndex & parent)
virtual Qt::ItemFlags flags(const QModelIndex & index) const
virtual bool hasChildren(const QModelIndex & parent = QModelIndex()) const
bool hasIndex(int row, int column, const QModelIndex & parent = QModelIndex()) const
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const
virtual QModelIndex index(int row, int column, const QModelIndex & parent = QModelIndex()) const = 0
bool insertColumn(int column, const QModelIndex & parent = QModelIndex())
virtual bool insertColumns(int column, int count, const QModelIndex & parent = QModelIndex())
bool insertRow(int row, const QModelIndex & parent = QModelIndex())
virtual bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex())
virtual QMap<int, QVariant> itemData(const QModelIndex & index) const
virtual QModelIndexList match(const QModelIndex & start, int role, const QVariant & value, int hits = 1, Qt::MatchFlags flags = Qt::MatchFlags( Qt::MatchStartsWith | Qt::MatchWrap )) const
virtual QMimeData * mimeData(const QModelIndexList & indexes) const
virtual QStringList mimeTypes() const
bool moveColumn(const QModelIndex & sourceParent, int sourceColumn, const QModelIndex & destinationParent, int destinationChild)
virtual bool moveColumns(const QModelIndex & sourceParent, int sourceColumn, int count, const QModelIndex & destinationParent, int destinationChild)
bool moveRow(const QModelIndex & sourceParent, int sourceRow, const QModelIndex & destinationParent, int destinationChild)
virtual bool moveRows(const QModelIndex & sourceParent, int sourceRow, int count, const QModelIndex & destinationParent, int destinationChild)
virtual QModelIndex parent(const QModelIndex & index) const = 0
bool removeColumn(int column, const QModelIndex & parent = QModelIndex())
virtual bool removeColumns(int column, int count, const QModelIndex & parent = QModelIndex())
bool removeRow(int row, const QModelIndex & parent = QModelIndex())
virtual bool removeRows(int row, int count, const QModelIndex & parent = QModelIndex())
virtual QHash<int, QByteArray> roleNames() const
virtual int rowCount(const QModelIndex & parent = QModelIndex()) const = 0
virtual bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole)
virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant & value, int role = Qt::EditRole)
virtual bool setItemData(const QModelIndex & index, const QMap<int, QVariant> & roles)
void setStringList(const QStringList & strings)
QModelIndex sibling(int row, int column, const QModelIndex & index) const
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder)
virtual QSize span(const QModelIndex & index) const
QStringList stringList() const
virtual Qt::DropActions supportedDragActions() const
virtual Qt::DropActions supportedDropActions() const

Reimplemented Public Functions

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)
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder)
virtual Qt::DropActions supportedDropActions() const

Public Slots

virtual void revert()
virtual bool submit()
  • 1 public slot inherited from QObject

Signals

void columnsAboutToBeInserted(const QModelIndex & parent, int start, int end)
void columnsAboutToBeMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationColumn)
void columnsAboutToBeRemoved(const QModelIndex & parent, int start, int end)
void columnsInserted(const QModelIndex & parent, int start, int end)
void columnsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationColumn)
void columnsRemoved(const QModelIndex & parent, int start, int end)
void dataChanged(const QModelIndex & topLeft, const QModelIndex & bottomRight, const QSet<int> & roles = QSet<int> ())
void headerDataChanged(Qt::Orientation orientation, int first, int last)
void layoutAboutToBeChanged(const QList<QPersistentModelIndex> & parents = QList<QPersistentModelIndex> ())
void layoutChanged(const QList<QPersistentModelIndex> & parents = QList<QPersistentModelIndex> ())
void modelAboutToBeReset()
void modelReset()
void rowsAboutToBeInserted(const QModelIndex & parent, int start, int end)
void rowsAboutToBeMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationRow)
void rowsAboutToBeRemoved(const QModelIndex & parent, int start, int end)
void rowsInserted(const QModelIndex & parent, int start, int end)
void rowsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationRow)
void rowsRemoved(const QModelIndex & parent, int start, int end)

Protected Functions

void beginInsertColumns(const QModelIndex & parent, int first, int last)
void beginInsertRows(const QModelIndex & parent, int first, int last)
bool beginMoveColumns(const QModelIndex & sourceParent, int sourceFirst, int sourceLast, const QModelIndex & destinationParent, int destinationChild)
bool beginMoveRows(const QModelIndex & sourceParent, int sourceFirst, int sourceLast, const QModelIndex & destinationParent, int destinationChild)
void beginRemoveColumns(const QModelIndex & parent, int first, int last)
void beginRemoveRows(const QModelIndex & parent, int first, int last)
void beginResetModel()
void changePersistentIndex(const QModelIndex & from, const QModelIndex & to)
void changePersistentIndexList(const QModelIndexList & from, const QModelIndexList & to)
QModelIndex createIndex(int row, int column, void * ptr = 0) const
QModelIndex createIndex(int row, int column, quint32 id) const
void endInsertColumns()
void endInsertRows()
void endMoveColumns()
void endMoveRows()
void endRemoveColumns()
void endRemoveRows()
void endResetModel()
QModelIndexList persistentIndexList() const
  • 9 protected functions inherited from QObject

Additional Inherited Members

  • 1 property inherited from QObject
  • 11 static public members inherited from QObject

Detailed Description

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.

Member Function Documentation

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]

Reimplemented from QAbstractItemModel::data().

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.

See also setData().

Qt::ItemFlags QStringListModel::flags(const QModelIndex & index) const [virtual]

Reimplemented from QAbstractItemModel::flags().

Returns the flags for the item with the given index.

Valid items are enabled, selectable, editable, drag enabled and drop enabled.

See also QAbstractItemModel::flags().

bool QStringListModel::insertRows(int row, int count, const QModelIndex & parent = QModelIndex()) [virtual]

Reimplemented from QAbstractItemModel::insertRows().

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.

See also QAbstractItemModel::insertRows().

bool QStringListModel::removeRows(int row, int count, const QModelIndex & parent = QModelIndex()) [virtual]

Reimplemented from QAbstractItemModel::removeRows().

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.

See also QAbstractItemModel::removeRows().

int QStringListModel::rowCount(const QModelIndex & parent = QModelIndex()) const [virtual]

Reimplemented from QAbstractItemModel::rowCount().

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.

See also insertRows(), removeRows(), and QAbstractItemModel::rowCount().

bool QStringListModel::setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole) [virtual]

Reimplemented from QAbstractItemModel::setData().

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.

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().

void QStringListModel::sort(int column, Qt::SortOrder order = Qt::AscendingOrder) [virtual]

Reimplemented from QAbstractItemModel::sort().

QStringList QStringListModel::stringList() const

Returns the string list used by the model to store data.

See also setStringList().

Qt::DropActions QStringListModel::supportedDropActions() const [virtual]

Reimplemented from QAbstractItemModel::supportedDropActions().

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web