QStringListModelclass provides a model that supplies strings to views. 更多 …
继承者: QHelpIndexModel
def
setStringList
(strings)
def
stringList
()
QStringListModelis 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 aQListView或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 withflags(). Item data is read with thedata()function and written withsetData(). The number of rows (and number of items in the string list) can be found with therowCount()函数。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 theinsertRows()function, and removed withremoveRows(). The contents of the string list can be retrieved with thestringList()convenience function.An example usage of
QStringListModel:QStringListModel *model = new QStringListModel(); QStringList list; list << "a" << "b" << "c"; model->setStringList(list);
QStringListModel
(
[
parent=None
]
)
¶
QStringListModel(strings[, parent=None])
- param parent
- param strings
字符串列表
Constructs a string list model with the given
parent
.
Constructs a string list model containing the specified
strings
采用给定
parent
.
PySide2.QtCore.QStringListModel.
setStringList
(
strings
)
¶
strings – 字符串列表
Sets the model’s internal string list to
strings
. The model will notify any attached views that its underlying data has changed.
另请参阅
stringList()
dataChanged()
PySide2.QtCore.QStringListModel.
stringList
(
)
¶
字符串列表
Returns the string list used by the model to store data.
另请参阅