File: qstringlistmodel.html

package info (click to toggle)
python-qt4 4.7.3-1%2Bsqueeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 28,504 kB
  • ctags: 4,680
  • sloc: python: 28,738; cpp: 8,897; sh: 245; xml: 243; makefile: 150
file content (63 lines) | stat: -rw-r--r-- 12,163 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QStringListModel Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QStringListModel Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QStringListModel class provides a model that supplies strings to views. <a href="#details">More...</a></p>
<p>Inherits <a href="qabstractlistmodel.html">QAbstractListModel</a>.</p><p>Inherited by <a href="qhelpindexmodel.html">QHelpIndexModel</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qstringlistmodel.html#QStringListModel">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qstringlistmodel.html#QStringListModel-2">__init__</a></b> (<i>self</i>, QStringList, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />QVariant <b><a href="qstringlistmodel.html#data">data</a></b> (<i>self</i>, QModelIndex, int)</li><li><div class="fn" />Qt.ItemFlags <b><a href="qstringlistmodel.html#flags">flags</a></b> (<i>self</i>, QModelIndex)</li><li><div class="fn" />bool <b><a href="qstringlistmodel.html#insertRows">insertRows</a></b> (<i>self</i>, int, int, QModelIndex&#160;<i>parent</i>&#160;=&#160;QModelIndex())</li><li><div class="fn" />bool <b><a href="qstringlistmodel.html#removeRows">removeRows</a></b> (<i>self</i>, int, int, QModelIndex&#160;<i>parent</i>&#160;=&#160;QModelIndex())</li><li><div class="fn" />int <b><a href="qstringlistmodel.html#rowCount">rowCount</a></b> (<i>self</i>, QModelIndex&#160;<i>parent</i>&#160;=&#160;QModelIndex())</li><li><div class="fn" />bool <b><a href="qstringlistmodel.html#setData">setData</a></b> (<i>self</i>, QModelIndex, QVariant, int&#160;<i>role</i>&#160;=&#160;Qt.EditRole)</li><li><div class="fn" /><b><a href="qstringlistmodel.html#setStringList">setStringList</a></b> (<i>self</i>, QStringList)</li><li><div class="fn" /><b><a href="qstringlistmodel.html#sort">sort</a></b> (<i>self</i>, int, Qt.SortOrder&#160;<i>order</i>&#160;=&#160;Qt.AscendingOrder)</li><li><div class="fn" />QStringList <b><a href="qstringlistmodel.html#stringList">stringList</a></b> (<i>self</i>)</li><li><div class="fn" />Qt.DropActions <b><a href="qstringlistmodel.html#supportedDropActions">supportedDropActions</a></b> (<i>self</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QStringListModel class provides a model that supplies strings to views.</p>
<p>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 <a href="qlistview.html">QListView</a> or a <a href="qcombobox.html">QComboBox</a>.</p>
<p>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.</p>
<p>Model indexes corresponding to items are obtained with the <a href="qabstractlistmodel.html#index">index()</a> function, and item flags are obtained with <a href="qstringlistmodel.html#flags">flags</a>(). Item data is read with the <a href="qstringlistmodel.html#data">data</a>() function and written with <a href="qstringlistmodel.html#setData">setData</a>(). The number of rows (and number of items in the string list) can be found with the <a href="qstringlistmodel.html#rowCount">rowCount</a>() function.</p>
<p>The model can be constructed with an existing string list, or strings can be set later with the <a href="qstringlistmodel.html#setStringList">setStringList</a>() convenience function. Strings can also be inserted in the usual way with the <a href="qstringlistmodel.html#insertRows">insertRows</a>() function, and removed with <a href="qstringlistmodel.html#removeRows">removeRows</a>(). The contents of the string list can be retrieved with the <a href="qstringlistmodel.html#stringList">stringList</a>() convenience function.</p>
<p>An example usage of QStringListModel:</p>
<pre>     QStringListModel *model = new QStringListModel();
     QStringList list;
     list &lt;&lt; "a" &lt;&lt; "b" &lt;&lt; "c";
     model-&gt;setStringList(list);</pre>
<p>See also <a href="qabstractlistmodel.html">QAbstractListModel</a>, <a href="qabstractitemmodel.html">QAbstractItemModel</a>, and <a href="model-view-model.html">Model Classes</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QStringListModel" />QStringListModel.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a string list model with the given <i>parent</i>.</p>
<h3 class="fn"><a name="QStringListModel-2" />QStringListModel.__init__ (<i>self</i>, QStringList, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a string list model containing the specified <i>strings</i> with the given <i>parent</i>.</p>
<a name="//apple_ref/cpp/instm/QStringListModel/data" />
<h3 class="fn"><a name="data" />QVariant QStringListModel.data (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>, int)</h3><p>Reimplemented from <a href="qabstractitemmodel.html#data">QAbstractItemModel.data</a>().</p>
<p>Returns data for the specified <i>role</i>, from the item with the given <i>index</i>.</p>
<p>If the view requests an invalid index, an invalid variant is returned.</p>
<p>See also <a href="qstringlistmodel.html#setData">setData</a>().</p>
<a name="//apple_ref/cpp/instm/QStringListModel/flags" />
<h3 class="fn"><a name="flags" /><a href="qt-itemflags.html">Qt.ItemFlags</a> QStringListModel.flags (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>)</h3><p>Reimplemented from <a href="qabstractitemmodel.html#flags">QAbstractItemModel.flags</a>().</p>
<p>Returns the flags for the item with the given <i>index</i>.</p>
<p>Valid items are enabled, selectable, editable, drag enabled and drop enabled.</p>
<p>See also <a href="qabstractitemmodel.html#flags">QAbstractItemModel.flags</a>().</p>
<a name="//apple_ref/cpp/instm/QStringListModel/insertRows" />
<h3 class="fn"><a name="insertRows" />bool QStringListModel.insertRows (<i>self</i>, int, int, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>parent</i>&#160;=&#160;QModelIndex())</h3><p>Reimplemented from <a href="qabstractitemmodel.html#insertRows">QAbstractItemModel.insertRows</a>().</p>
<p>Inserts <i>count</i> rows into the model, beginning at the given <i>row</i>.</p>
<p>The <i>parent</i> index of the rows is optional and is only used for consistency with <a href="qabstractitemmodel.html">QAbstractItemModel</a>. By default, a null index is specified, indicating that the rows are inserted in the top level of the model.</p>
<p>See also <a href="qabstractitemmodel.html#insertRows">QAbstractItemModel.insertRows</a>().</p>
<a name="//apple_ref/cpp/instm/QStringListModel/removeRows" />
<h3 class="fn"><a name="removeRows" />bool QStringListModel.removeRows (<i>self</i>, int, int, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>parent</i>&#160;=&#160;QModelIndex())</h3><p>Reimplemented from <a href="qabstractitemmodel.html#removeRows">QAbstractItemModel.removeRows</a>().</p>
<p>Removes <i>count</i> rows from the model, beginning at the given <i>row</i>.</p>
<p>The <i>parent</i> index of the rows is optional and is only used for consistency with <a href="qabstractitemmodel.html">QAbstractItemModel</a>. By default, a null index is specified, indicating that the rows are removed in the top level of the model.</p>
<p>See also <a href="qabstractitemmodel.html#removeRows">QAbstractItemModel.removeRows</a>().</p>
<a name="//apple_ref/cpp/instm/QStringListModel/rowCount" />
<h3 class="fn"><a name="rowCount" />int QStringListModel.rowCount (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>&#160;<i>parent</i>&#160;=&#160;QModelIndex())</h3><p>Reimplemented from <a href="qabstractitemmodel.html#rowCount">QAbstractItemModel.rowCount</a>().</p>
<p>Returns the number of rows in the model. This value corresponds to the number of items in the model's internal string list.</p>
<p>The optional <i>parent</i> 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.</p>
<p>See also <a href="qstringlistmodel.html#insertRows">insertRows</a>(), <a href="qstringlistmodel.html#removeRows">removeRows</a>(), and <a href="qabstractitemmodel.html#rowCount">QAbstractItemModel.rowCount</a>().</p>
<a name="//apple_ref/cpp/instm/QStringListModel/setData" />
<h3 class="fn"><a name="setData" />bool QStringListModel.setData (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a>, QVariant, int&#160;<i>role</i>&#160;=&#160;Qt.EditRole)</h3><p>Reimplemented from <a href="qabstractitemmodel.html#setData">QAbstractItemModel.setData</a>().</p>
<p>Sets the data for the specified <i>role</i> in the item with the given <i>index</i> in the model, to the provided <i>value</i>.</p>
<p>The <a href="qabstractitemmodel.html#dataChanged">dataChanged</a>() signal is emitted if the item is changed.</p>
<p>See also <a href="qt.html#ItemDataRole-enum">Qt.ItemDataRole</a> and <a href="qstringlistmodel.html#data">data</a>().</p>
<a name="//apple_ref/cpp/instm/QStringListModel/setStringList" />
<h3 class="fn"><a name="setStringList" />QStringListModel.setStringList (<i>self</i>, QStringList)</h3><p>Sets the model's internal string list to <i>strings</i>. The model will notify any attached views that its underlying data has changed.</p>
<p>See also <a href="qstringlistmodel.html#stringList">stringList</a>() and <a href="qabstractitemmodel.html#dataChanged">dataChanged</a>().</p>
<a name="//apple_ref/cpp/instm/QStringListModel/sort" />
<h3 class="fn"><a name="sort" />QStringListModel.sort (<i>self</i>, int, <a href="qt.html#SortOrder-enum">Qt.SortOrder</a>&#160;<i>order</i>&#160;=&#160;Qt.AscendingOrder)</h3><p>Reimplemented from <a href="qabstractitemmodel.html#sort">QAbstractItemModel.sort</a>().</p>
<a name="//apple_ref/cpp/instm/QStringListModel/stringList" />
<h3 class="fn"><a name="stringList" />QStringList QStringListModel.stringList (<i>self</i>)</h3><p>Returns the string list used by the model to store data.</p>
<p>See also <a href="qstringlistmodel.html#setStringList">setStringList</a>().</p>
<a name="//apple_ref/cpp/instm/QStringListModel/supportedDropActions" />
<h3 class="fn"><a name="supportedDropActions" /><a href="qt-dropactions.html">Qt.DropActions</a> QStringListModel.supportedDropActions (<i>self</i>)</h3><p>Reimplemented from <a href="qabstractitemmodel.html#supportedDropActions">QAbstractItemModel.supportedDropActions</a>().</p>
<p /><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.7.3 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt&#160;4.6.2</td></tr></table></div></address></body></html>