QStringListModel Class▲
-
Header: QStringListModel
-
CMake:
find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
-
qmake: QT += core
-
Inherits: https://
-
Group: QStringListModel is part of model-view
Detailed Description▲
https:// 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 https://() function, and item flags are obtained with https://(). Item data is read with the https://() function and written with https://(). The number of rows (and number of items in the string list) can be found with the https://() function.
The model can be constructed with an existing string list, or strings can be set later with the https://() convenience function. Strings can also be inserted in the usual way with the https://() function, and removed with https://(). The contents of the string list can be retrieved with the https://() convenience function.
An example usage of https://:
QStringListModel *model = new QStringListModel();
QStringList list;
list << "a" << "b" << "c";
model->setStringList(list);See Also▲
See also https://, https://, Model Classes
Member Function Documentation▲
[explicit] QStringListModel::QStringListModel(QObject *parent = nullptr)▲
Constructs a string list model with the given parent.
[explicit] QStringListModel::QStringListModel(const QStringList &strings, QObject *parent = nullptr)▲
Constructs a string list model containing the specified strings with the given parent.
[override virtual, since 6.0] bool QStringListModel::clearItemData(const QModelIndex &index)▲
Reimplements: https://.
This function was introduced in Qt 6.0.
[override virtual] QVariant QStringListModel::data(const QModelIndex &index, int role = Qt::DisplayRole) const▲
Reimplements: https://.
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▲
See also https://()
[override virtual] Qt::ItemFlags QStringListModel::flags(const QModelIndex &index) const▲
Reimplements: https://.
Returns the flags for the item with the given index.
Valid items are enabled, selectable, editable, drag enabled and drop enabled.
See Also▲
See also https://()
[override virtual] bool QStringListModel::insertRows(int row, int count, const QModelIndex &parent = QModelIndex())▲
Reimplements: https://.
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 https://. By default, a null index is specified, indicating that the rows are inserted in the top level of the model.
Returns true if the insertion was successful.
See Also▲
See also https://()
[override virtual, since 5.13] QMap<int, QVariant> QStringListModel::itemData(const QModelIndex &index) const▲
[override virtual, since 5.13] bool QStringListModel::moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)▲
Reimplements: https://.
This function was introduced in Qt 5.13.
[override virtual] bool QStringListModel::removeRows(int row, int count, const QModelIndex &parent = QModelIndex())▲
Reimplements: https://.
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 https://. By default, a null index is specified, indicating that the rows are removed in the top level of the model.
Returns true if the row removal was successful.
See Also▲
See also https://()
[override virtual] int QStringListModel::rowCount(const QModelIndex &parent = QModelIndex()) const▲
Reimplements: https://.
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▲
See also https://(), https://(), https://()
[override virtual] bool QStringListModel::setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole)▲
Reimplements: https://.
Sets the data for the specified role in the item with the given index in the model, to the provided value.
The https://() signal is emitted if the item is changed. Returns true after emitting the https://() signal.
See Also▲
See also https://, https://()
[override virtual, since 5.13] bool QStringListModel::setItemData(const QModelIndex &index, const QMap<int, QVariant> &roles)▲
Reimplements: https://.
If roles contains both https:// and https://, the latter will take precedence
This function was introduced in Qt 5.13.
See Also▲
See also https://()
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▲
See also https://(), https://()
[override virtual] QModelIndex QStringListModel::sibling(int row, int column, const QModelIndex &idx) const▲
Reimplements: https://.
[override virtual] void QStringListModel::sort(int column, Qt::SortOrder order = Qt::AscendingOrder)▲
Reimplements: https://.
QStringList QStringListModel::stringList() const▲
[override virtual] Qt::DropActions QStringListModel::supportedDropActions() const▲
Reimplements: https://.


