Overview | Package | Class | Tree | Deprecated | Index | Help
Qt Jambi Home |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QStringListModel

    java.lang.Object
      com.trolltech.qt.QSignalEmitter
          com.trolltech.qt.QtJambiObject
              com.trolltech.qt.core.QObject
                  com.trolltech.qt.core.QAbstractItemModel
                      com.trolltech.qt.core.QAbstractListModel
                          com.trolltech.qt.gui.QStringListModel

All Implemented Interfaces:
  QtJambiInterface

    public class QStringListModel

extends QAbstractListModel

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`, Model Classes

Nested Class Summary

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>`

Field Summary

Fields inherited from class com.trolltech.qt.core.QAbstractItemModel
`dataChanged, headerDataChanged, layoutAboutToBeChanged, layoutChanged`

Constructor Summary
`QStringListModel()` Equivalent to `QStringListModel`(0).
`QStringListModel(java.util.List<java.lang.String> strings)` Equivalent to `QStringListModel`(`strings`, 0).
`QStringListModel(java.util.List<java.lang.String> strings, QObject parent)` Constructs a string list model containing the specified `strings` with the given `parent`.
`QStringListModel(QObject parent)` Constructs a string list model with the given `parent`.

Method Summary
`java.lang.Object` | `data(QModelIndex index, int role)` Returns data for the specified `role`, from the item with the given `index`.
`Qt.ItemFlags` | `flags(QModelIndex index)` Returns the flags for the item with the given `index`.
`static QStringListModel` | `fromNativePointer(QNativePointer nativePointer)` This function returns the QStringListModel instance pointed to by nativePointer
`boolean` | `insertRows(int row, int count, QModelIndex parent)` Inserts `count` rows into the model, beginning at the given `row`.
`boolean` | `removeRows(int row, int count, QModelIndex parent)` Removes `count` rows from the model, beginning at the given `row`.
`int` | `rowCount(QModelIndex parent)` Returns the number of rows in the model.
`boolean` | `setData(QModelIndex index, java.lang.Object value, int role)` Sets the data for the specified `role` in the item with the given `index` in the model, to the provided `value`.
`void` | `setStringList(java.util.List<java.lang.String> strings)` Sets the model's internal string list to `strings`.
`void` | `sort(int column, Qt.SortOrder order)` This function is reimplemented for internal reasons.
`java.util.List<java.lang.String>` | `stringList()` Returns the string list used by the model to store data.

Methods inherited from class com.trolltech.qt.core.QAbstractListModel
`columnCount, dropMimeData, hasChildren, index, parent`

Methods inherited from class com.trolltech.qt.core.QAbstractItemModel
`beginInsertColumns, beginInsertRows, beginRemoveColumns, beginRemoveRows, buddy, canFetchMore, changePersistentIndex, changePersistentIndexList, columnCount, createIndex, createIndex, createIndex, data, data, data, decodeData, encodeData, endInsertColumns, endInsertRows, endRemoveColumns, endRemoveRows, fetchMore, hasChildren, hasIndex, hasIndex, headerData, headerData, index, insertColumn, insertColumn, insertColumns, insertColumns, insertRow, insertRow, insertRows, itemData, match, match, match, match, mimeData, mimeTypes, persistentIndexList, removeColumn, removeColumn, removeColumns, removeColumns, removeRow, removeRow, removeRows, reset, revert, rowCount, setData, setData, setData, setHeaderData, setHeaderData, setItemData, setSupportedDragActions, setSupportedDragActions, sibling, sort, span, submit, supportedDragActions, supportedDropActions`

Methods inherited from class com.trolltech.qt.core.QObject
`blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent`

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`disconnect, disconnect, signalSender`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Constructor Detail

### QStringListModel

    public QStringListModel()

  Equivalent to `QStringListModel`(0).

### QStringListModel

    public QStringListModel(QObject parent)

  Constructs a string list model with the given `parent`.

### QStringListModel

    public QStringListModel(java.util.List<java.lang.String> strings)

  Equivalent to `QStringListModel`(`strings`, 0).

### QStringListModel

    public QStringListModel(java.util.List<java.lang.String> strings,
                            QObject parent)

  Constructs a string list model containing the specified `strings` with the given `parent`.

Method Detail

### setStringList

    public final void setStringList(java.util.List<java.lang.String> 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`, `dataChanged`

### stringList

    public final java.util.List<java.lang.String> stringList()

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

  See Also:
    `setStringList`

### data

    public java.lang.Object data(QModelIndex index,
                                 int role)

  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.

  Specified by:
    `data` in class `QAbstractItemModel`
  See Also:
    `setData`

### flags

    public Qt.ItemFlags flags(QModelIndex index)

  Returns the flags for the item with the given `index`.

  Valid items are enabled, selectable, and editable.

  Overrides:
    `flags` in class `QAbstractItemModel`
  See Also:
    `QAbstractItemModel::flags`

### insertRows

    public boolean insertRows(int row,
                              int count,
                              QModelIndex parent)

  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.

  Overrides:
    `insertRows` in class `QAbstractItemModel`
  See Also:
    `QAbstractItemModel::insertRows`

### removeRows

    public boolean removeRows(int row,
                              int count,
                              QModelIndex parent)

  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.

  Overrides:
    `removeRows` in class `QAbstractItemModel`
  See Also:
    `QAbstractItemModel::removeRows`

### rowCount

    public int rowCount(QModelIndex parent)

  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.

  Specified by:
    `rowCount` in class `QAbstractItemModel`
  See Also:
    `insertRows`, `removeRows`, `QAbstractItemModel::rowCount`

### setData

    public boolean setData(QModelIndex index,
                           java.lang.Object value,
                           int role)

  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.

  Overrides:
    `setData` in class `QAbstractItemModel`
  See Also:
    `Qt::ItemDataRole`, `data`

### sort

    public void sort(int column,
                     Qt.SortOrder order)

  This function is reimplemented for internal reasons.

  Overrides:
    `sort` in class `QAbstractItemModel`

### fromNativePointer

    public static QStringListModel fromNativePointer(QNativePointer nativePointer)

  This function returns the QStringListModel instance pointed to by nativePointer

  Parameters:
    `nativePointer` - the QNativePointer of which object should be returned.

Overview | Package | Class | Tree | Deprecated | Index | Help
Qt Jambi Home |
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD