com.trolltech.qt.gui
Class QStringListModel

java.lang.Object
  extended by com.trolltech.qt.internal.QSignalEmitterInternal
      extended by com.trolltech.qt.QSignalEmitter
          extended by com.trolltech.qt.QtJambiObject
              extended by com.trolltech.qt.core.QObject
                  extended by com.trolltech.qt.core.QAbstractItemModel
                      extended by com.trolltech.qt.core.QAbstractListModel
                          extended by 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();
        List<String> list = new Vector<String>();
        list.add("a");
        list.add("b");
        list.add("c");
        model.setStringList(list);
    

See also:
QAbstractListModel, QAbstractItemModel, and Model Classes.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
QSignalEmitter.AbstractSignal, QSignalEmitter.PrivateSignal0, QSignalEmitter.PrivateSignal1, QSignalEmitter.PrivateSignal2, QSignalEmitter.PrivateSignal3, QSignalEmitter.PrivateSignal4, QSignalEmitter.PrivateSignal5, QSignalEmitter.PrivateSignal6, QSignalEmitter.PrivateSignal7, QSignalEmitter.PrivateSignal8, QSignalEmitter.PrivateSignal9, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9
 
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal
 
Field Summary
 
Fields inherited from class com.trolltech.qt.core.QAbstractItemModel
columnsAboutToBeInserted, columnsAboutToBeRemoved, columnsInserted, columnsRemoved, dataChanged, headerDataChanged, layoutAboutToBeChanged, layoutChanged, modelAboutToBeReset, modelReset, rowsAboutToBeInserted, rowsAboutToBeRemoved, rowsInserted, rowsRemoved
 
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
currentSender
 
Constructor Summary
QStringListModel()
          Constructs a string list model with the given parent.
QStringListModel(java.util.List strings)
          Constructs a string list model containing the specified strings with the given parent.
QStringListModel(java.util.List 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
 void setStringList(java.util.List strings)
          Sets the model's internal string list to strings.
 java.util.List stringList()
          Returns the string list used by the model to store data.
 
Methods inherited from class com.trolltech.qt.core.QAbstractItemModel
beginInsertColumns, beginInsertRows, beginRemoveColumns, beginRemoveRows, buddy, canFetchMore, changePersistentIndex, changePersistentIndexList, columnCount, columnCount, createIndex, createIndex, createIndex, data, data, data, data, dropMimeData, endInsertColumns, endInsertRows, endRemoveColumns, endRemoveRows, fetchMore, flags, hasChildren, hasChildren, hasIndex, hasIndex, headerData, headerData, index, index, insertColumn, insertColumn, insertColumns, insertColumns, insertRow, insertRow, insertRows, insertRows, itemData, match, match, match, match, mimeData, mimeTypes, parent, persistentIndexList, removeColumn, removeColumn, removeColumns, removeColumns, removeRow, removeRow, removeRows, removeRows, reset, revert, rowCount, rowCount, setData, setData, setData, setData, setHeaderData, setHeaderData, setItemData, setSupportedDragActions, setSupportedDragActions, sibling, sort, sort, span, submit, supportedDragActions, supportedDropActions
 
Methods inherited from class com.trolltech.qt.core.QObject
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread
 
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
__qt_signalInitialization
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Constructor Detail

QStringListModel

public QStringListModel()
Constructs a string list model with the given parent.


QStringListModel

public QStringListModel(QObject parent)
Constructs a string list model with the given parent.


QStringListModel

public QStringListModel(java.util.List strings)
Constructs a string list model containing the specified strings with the given parent.


QStringListModel

public QStringListModel(java.util.List 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 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() .


stringList

public final java.util.List stringList()
Returns the string list used by the model to store data.

See also:
setStringList().