Qyoto
4.0.5
Qyoto is a C# language binding for Qt
|
The QStandardItemModel class provides a generic model for storing custom data. More...
Public Member Functions | |
QStandardItemModel (QObject parent=null) | |
| |
QStandardItemModel (int rows, int columns, QObject parent=null) | |
| |
override void | CreateProxy () |
new void | AppendColumn (System.Collections.Generic.List< QStandardItem > items) |
| |
new void | AppendRow (QStandardItem item) |
| |
new void | AppendRow (System.Collections.Generic.List< QStandardItem > items) |
| |
new void | Clear () |
| |
new int | ColumnCount () |
| |
override int | ColumnCount (QModelIndex parent) |
| |
override object | Data (QModelIndex index, int role=(int) Qt.ItemDataRole.DisplayRole) |
| |
override bool | DropMimeData (QMimeData data, Qt.DropAction action, int row, int column, QModelIndex parent) |
| |
new System.Collections.Generic.List < QStandardItem > | FindItems (string text, Qt.MatchFlag flags=Qt.MatchFlag.MatchExactly, int column=0) |
| |
override Qt.ItemFlag | Flags (QModelIndex index) |
| |
new bool | HasChildren () |
| |
override bool | HasChildren (QModelIndex parent) |
| |
override object | HeaderData (int section, Qt.Orientation orientation, int role=(int) Qt.ItemDataRole.DisplayRole) |
| |
new QStandardItem | HorizontalHeaderItem (int column) |
| |
new QModelIndex | Index (int row, int column) |
| |
override QModelIndex | Index (int row, int column, QModelIndex parent) |
| |
new QModelIndex | IndexFromItem (QStandardItem item) |
| |
new bool | InsertColumn (int column) |
| |
new bool | InsertColumn (int column, QModelIndex parent) |
| |
new void | InsertColumn (int column, System.Collections.Generic.List< QStandardItem > items) |
| |
new bool | InsertColumns (int column, int count) |
| |
override bool | InsertColumns (int column, int count, QModelIndex parent) |
| |
new bool | InsertRow (int row) |
| |
new void | InsertRow (int row, QStandardItem item) |
| |
new bool | InsertRow (int row, QModelIndex parent) |
| |
new void | InsertRow (int row, System.Collections.Generic.List< QStandardItem > items) |
| |
new bool | InsertRows (int row, int count) |
| |
override bool | InsertRows (int row, int count, QModelIndex parent) |
| |
new QStandardItem | InvisibleRootItem () |
| |
new QStandardItem | Item (int row, int column=0) |
| |
override System.Collections.Generic.Dictionary < System.Int32, System.Object > | ItemData (QModelIndex index) |
| |
new QStandardItem | ItemFromIndex (QModelIndex index) |
| |
override QMimeData | MimeData (System.Collections.Generic.List< QModelIndex > indexes) |
| |
override System.Collections.Generic.List < string > | MimeTypes () |
| |
new QObject | parent () |
| |
override QModelIndex | Parent (QModelIndex child) |
| |
new bool | RemoveColumns (int column, int count) |
| |
override bool | RemoveColumns (int column, int count, QModelIndex parent) |
| |
new bool | RemoveRows (int row, int count) |
| |
override bool | RemoveRows (int row, int count, QModelIndex parent) |
| |
new int | RowCount () |
| |
override int | RowCount (QModelIndex parent) |
| |
new void | SetColumnCount (int columns) |
| |
override bool | SetData (QModelIndex index, object value, int role=(int) Qt.ItemDataRole.EditRole) |
| |
override bool | SetHeaderData (int section, Qt.Orientation orientation, object value, int role=(int) Qt.ItemDataRole.EditRole) |
| |
new void | SetHorizontalHeaderItem (int column, QStandardItem item) |
| |
new void | SetHorizontalHeaderLabels (System.Collections.Generic.List< string > labels) |
| |
new void | SetItem (int row, QStandardItem item) |
| |
new void | SetItem (int row, int column, QStandardItem item) |
| |
override bool | SetItemData (QModelIndex index, System.Collections.Generic.Dictionary< System.Int32, System.Object > roles) |
| |
new void | SetRowCount (int rows) |
| |
new void | SetVerticalHeaderItem (int row, QStandardItem item) |
| |
new void | SetVerticalHeaderLabels (System.Collections.Generic.List< string > labels) |
| |
override void | Sort (int column, Qt.SortOrder order=Qt.SortOrder.AscendingOrder) |
| |
override Qt.DropAction | SupportedDropActions () |
| |
new System.Collections.Generic.List < QStandardItem > | TakeColumn (int column) |
| |
new QStandardItem | TakeHorizontalHeaderItem (int column) |
| |
new QStandardItem | TakeItem (int row, int column=0) |
| |
new System.Collections.Generic.List < QStandardItem > | TakeRow (int row) |
| |
new QStandardItem | TakeVerticalHeaderItem (int row) |
| |
new QStandardItem | VerticalHeaderItem (int row) |
| |
new void | Dispose () |
Public Member Functions inherited from QtCore.QAbstractItemModel | |
QAbstractItemModel (QObject parent=null) | |
| |
virtual QModelIndex | Buddy (QModelIndex index) |
| |
virtual bool | CanFetchMore (QModelIndex parent) |
| |
virtual void | FetchMore (QModelIndex parent) |
| |
new bool | HasChildren () |
| |
new bool | HasIndex (int row, int column) |
| |
new bool | HasIndex (int row, int column, QModelIndex parent) |
| |
new QModelIndex | Index (int row, int column) |
| |
new bool | InsertColumn (int column) |
| |
new bool | InsertColumn (int column, QModelIndex parent) |
| |
new bool | InsertColumns (int column, int count) |
| |
new bool | InsertRow (int row) |
| |
new bool | InsertRow (int row, QModelIndex parent) |
| |
new bool | InsertRows (int row, int count) |
| |
virtual System.Collections.Generic.List < QModelIndex > | Match (QModelIndex start, int role, object value, int hits=1, Qt.MatchFlag flags=Qt.MatchFlag.MatchStartsWith|Qt.MatchFlag.MatchWrap) |
| |
new QObject | Parent () |
| |
new bool | RemoveColumn (int column) |
| |
new bool | RemoveColumn (int column, QModelIndex parent) |
| |
new bool | RemoveColumns (int column, int count) |
| |
new bool | RemoveRow (int row) |
| |
new bool | RemoveRow (int row, QModelIndex parent) |
| |
new bool | RemoveRows (int row, int count) |
| |
virtual void | Revert () |
| |
new System.Collections.Generic.Dictionary < System.Int32, QByteArray > | RoleNames () |
| |
new int | RowCount () |
| |
new QModelIndex | Sibling (int row, int column, QModelIndex idx) |
| |
virtual QSize | Span (QModelIndex index) |
| |
virtual bool | Submit () |
| |
new void | Dispose () |
Public Member Functions inherited from QtCore.QObject | |
QObject (QObject parent=null) | |
| |
new bool | BlockSignals (bool b) |
| |
new System.Collections.Generic.List < QObject > | Children () |
| |
new bool | Connect (QObject sender, string signal, string member, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
| |
new void | DeleteLater () |
| |
new bool | Disconnect (QObject receiver, string member=null) |
| |
new bool | Disconnect (string signal=null, QObject receiver=null, string member=null) |
| |
new void | DumpObjectInfo () |
| |
new void | DumpObjectTree () |
| |
new System.Collections.Generic.List < QByteArray > | DynamicPropertyNames () |
| |
virtual bool | OnEvent (QEvent arg1) |
| |
virtual bool | EventFilter (QObject arg1, QEvent arg2) |
| |
new bool | Inherits (string classname) |
| |
new void | InstallEventFilter (QObject arg1) |
| |
new bool | IsWidgetType () |
| |
new void | KillTimer (int id) |
| |
new object | Property (string name) |
| |
new void | RemoveEventFilter (QObject arg1) |
| |
new bool | SetProperty (string name, object value) |
| |
new void | SetUserData (uint id, QObjectUserData data) |
new bool | SignalsBlocked () |
| |
new int | StartTimer (int interval) |
| |
new QObjectUserData | UserData (uint id) |
new void | Dispose () |
Public Member Functions inherited from QtCore.Qt | |
delegate QTextStream | FuncQTextStreamQTextStream (QTextStream qTextStream) |
delegate string | FuncStringQByteArray (QByteArray qByteArray) |
delegate QByteArray | FuncQByteArrayString (string @string) |
delegate void | ActionQtMsgTypeString (QtMsgType qtMsgType, string @string) |
delegate QObject | FuncQObject () |
Static Public Member Functions | |
static string | Tr (string s, string c=null) |
static string | Tr (string s, string c, int n) |
static string | TrUtf8 (string s, string c=null) |
static string | TrUtf8 (string s, string c, int n) |
Static Public Member Functions inherited from QtCore.QAbstractItemModel | |
static string | Tr (string s, string c=null) |
static string | Tr (string s, string c, int n) |
static string | TrUtf8 (string s, string c=null) |
static string | TrUtf8 (string s, string c, int n) |
Static Public Member Functions inherited from QtCore.QObject | |
static bool | Connect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod method, Qt.ConnectionType type=Qt.ConnectionType.AutoConnection) |
| |
static bool | Connect (QObject sender, string signal, QObject receiver, string member, Qt.ConnectionType arg5=Qt.ConnectionType.AutoConnection) |
| |
static bool | Disconnect (QObject sender, QMetaMethod signal, QObject receiver, QMetaMethod member) |
| |
static bool | Disconnect (QObject sender, string signal, QObject receiver, string member) |
| |
static uint | RegisterUserData () |
static string | Tr (string s, string c=null) |
| |
static string | Tr (string s, string c, int n) |
| |
static string | TrUtf8 (string s, string c=null) |
| |
static string | TrUtf8 (string s, string c, int n) |
| |
Static Public Member Functions inherited from QtCore.Qt | |
static QDataStream | Write (QDataStream s, object p) |
static QDataStream | Write (QDataStream arg1, QSizeF arg2) |
static QTextStream | Write (QTextStream s, Qt.FuncQTextStreamQTextStream f) |
static QDataStream | Write (QDataStream arg1, QPoint arg2) |
static QDataStream | Write (QDataStream arg1, QLineF arg2) |
static QDataStream | Write (QDataStream arg1, QPointF arg2) |
static QDataStream | Write (QDataStream arg1, QChar arg2) |
static QDataStream | Write (QDataStream arg1, QByteArray arg2) |
static QDataStream | Write (QDataStream arg1, QEasingCurve arg2) |
static QDataStream | Write (QDataStream arg1, QRectF arg2) |
static QDataStream | Write (QDataStream arg1, QDateTime arg2) |
static QDataStream | Write (QDataStream arg1, QUrl arg2) |
static QDataStream | Write (QDataStream arg1, QTime arg2) |
static QDataStream | Write (QDataStream arg1, QLocale arg2) |
static QDataStream | Write (QDataStream arg1, QBitArray arg2) |
static QDataStream | Write (QDataStream arg1, QUuid arg2) |
static QDataStream | Write (QDataStream arg1, QLine arg2) |
static QDataStream | Write (QDataStream arg1, QDate arg2) |
static QDataStream | Write (QDataStream @out, QRegExp regExp) |
static QDataStream | Write (QDataStream arg1, QRect arg2) |
static QDataStream | Write (QDataStream arg1, QSize arg2) |
static QDataStream | Write (QDataStream s, QVariant.Type p) |
static QDataStream | Write (QDataStream arg1, string arg2) |
static QDataStream | Write (QDataStream @out, System.Collections.Generic.List< string > list) |
static QDataStream | Read (QDataStream arg1, QChar arg2) |
static QDataStream | Read (QDataStream arg1, QLocale arg2) |
static QDataStream | Read (QDataStream arg1, QRect arg2) |
static QDataStream | Read (QDataStream arg1, QEasingCurve arg2) |
static QDataStream | Read (QDataStream arg1, QDate arg2) |
static QDataStream | Read (QDataStream arg1, QUrl arg2) |
static QDataStream | Read (QDataStream arg1, QUuid arg2) |
static QTextStream | Read (QTextStream s, Qt.FuncQTextStreamQTextStream f) |
static QDataStream | Read (QDataStream arg1, QLineF arg2) |
static QDataStream | Read (QDataStream arg1, QRectF arg2) |
static QDataStream | Read (QDataStream arg1, QPointF arg2) |
static QDataStream | Read (QDataStream arg1, QLine arg2) |
static QDataStream | Read (QDataStream arg1, QBitArray arg2) |
static QDataStream | Read (QDataStream arg1, QSize arg2) |
static QDataStream | Read (QDataStream arg1, QDateTime arg2) |
static QDataStream | Read (QDataStream arg1, QTime arg2) |
static QDataStream | Read (QDataStream arg1, QPoint arg2) |
static QDataStream | Read (QDataStream @in, QRegExp regExp) |
static QDataStream | Read (QDataStream s, object p) |
static QDataStream | Read (QDataStream arg1, QByteArray arg2) |
static QDataStream | Read (QDataStream arg1, QSizeF arg2) |
static QDataStream | Read (QDataStream arg1, string arg2) |
static QDataStream | Read (QDataStream s, QVariant.Type p) |
static QDataStream | Read (QDataStream @in, System.Collections.Generic.List< string > list) |
static double | qAcos (double v) |
static void | qAddPostRoutine (System.Action arg1) |
static string | qAppName () |
static double | qAsin (double v) |
static double | qAtan (double v) |
static double | qAtan2 (double x, double y) |
static void | qBadAlloc () |
static int | qCeil (double v) |
static ushort | qChecksum (string s, uint len) |
static QByteArray | qCompress (QByteArray data) |
static QByteArray | qCompress (QByteArray data, int compressionLevel=-1) |
static QByteArray | qCompress (Pointer< byte > data, int nbytes) |
static QByteArray | qCompress (Pointer< byte > data, int nbytes, int compressionLevel=-1) |
static double | qCos (double v) |
static double | qExp (double v) |
static double | qFabs (double v) |
static double | qFastCos (double x) |
static double | qFastSin (double x) |
static string | qFlagLocation (string method) |
static int | qFloor (double v) |
static bool | qFuzzyCompare (double p1, double p2) |
static bool | qFuzzyCompare (float p1, float p2) |
static bool | qFuzzyIsNull (double d) |
static bool | qFuzzyIsNull (float f) |
static uint | qHash (QBitArray key) |
static uint | qHash (QChar key) |
static uint | qHash (QStringRef key) |
static uint | qHash (QUrl url) |
static uint | qHash (QPersistentModelIndex index) |
static uint | qHash (QByteArray key) |
static uint | qHash (QModelIndex index) |
static uint | qHash (uint key) |
static uint | qHash (sbyte key) |
static uint | qHash (byte key) |
static uint | qHash (short key) |
static uint | qHash (NativeLong key) |
static uint | qHash (ushort key) |
static uint | qHash (long key) |
static uint | qHash (ulong key) |
static uint | qHash (int key) |
static uint | qHash (string key) |
static uint | qHash (NativeULong key) |
static double | qInf () |
static Qt.ActionQtMsgTypeString | qInstallMsgHandler (Qt.ActionQtMsgTypeString arg1) |
static int | qIntCast (float f) |
static int | qIntCast (double f) |
static bool | qIsFinite (double d) |
static bool | qIsFinite (float f) |
static bool | qIsInf (float f) |
static bool | qIsInf (double d) |
static bool | qIsNaN (float f) |
static bool | qIsNaN (double d) |
static bool | qIsNull (float f) |
static bool | qIsNull (double d) |
static double | qLn (double v) |
static double | qPow (double x, double y) |
static double | qQNaN () |
static void | qRegisterStaticPluginInstanceFunction (Qt.FuncQObject function) |
static void | qRemovePostRoutine (System.Action arg1) |
static int | qRound (double d) |
static long | qRound64 (double d) |
static double | qSNaN () |
static bool | qSharedBuild () |
static double | qSin (double v) |
static double | qSqrt (double v) |
static bool | qStringComparisonHelper (QStringRef s1, string s2) |
static double | qTan (double v) |
static QByteArray | qUncompress (QByteArray data) |
static QByteArray | qUncompress (Pointer< byte > data, int nbytes) |
static string | qVersion () |
static void | Qbswap_helper (Pointer< byte > src, Pointer< byte > dest, int size) |
static QByteArray | Qgetenv (string varName) |
static bool | Qputenv (string varName, QByteArray value) |
static int | Qrand () |
static void | Qsrand (uint seed) |
static int | Qstrcmp (QByteArray str1, QByteArray str2) |
static int | Qstrcmp (QByteArray str1, string str2) |
static int | Qstrcmp (string str1, QByteArray str2) |
static int | Qstrcmp (string str1, string str2) |
static Pointer< sbyte > | Qstrcpy (Pointer< sbyte > dst, string src) |
static Pointer< sbyte > | Qstrdup (string arg1) |
static int | Qstricmp (string arg1, string arg2) |
static uint | Qstrlen (string str) |
static int | Qstrncmp (string str1, string str2, uint len) |
static Pointer< sbyte > | Qstrncpy (Pointer< sbyte > dst, string src, uint len) |
static int | Qstrnicmp (string arg1, string arg2, uint len) |
static uint | Qstrnlen (string str, uint maxlen) |
static string | QtTrId (string id, int n=-1) |
Protected Member Functions | |
QStandardItemModel (System.Type dummy) | |
new void | OnItemChanged (QStandardItem item) |
| |
Protected Member Functions inherited from QtCore.QAbstractItemModel | |
QAbstractItemModel (System.Type dummy) | |
new void | BeginInsertColumns (QModelIndex parent, int first, int last) |
| |
new void | BeginInsertRows (QModelIndex parent, int first, int last) |
| |
new bool | BeginMoveColumns (QModelIndex sourceParent, int sourceFirst, int sourceLast, QModelIndex destinationParent, int destinationColumn) |
| |
new bool | BeginMoveRows (QModelIndex sourceParent, int sourceFirst, int sourceLast, QModelIndex destinationParent, int destinationRow) |
| |
new void | BeginRemoveColumns (QModelIndex parent, int first, int last) |
| |
new void | BeginRemoveRows (QModelIndex parent, int first, int last) |
| |
new void | BeginResetModel () |
| |
new void | ChangePersistentIndex (QModelIndex from, QModelIndex to) |
| |
new void | ChangePersistentIndexList (System.Collections.Generic.List< QModelIndex > from, System.Collections.Generic.List< QModelIndex > to) |
| |
new QModelIndex | CreateIndex (int row, int column) |
| |
new QModelIndex | CreateIndex (int row, int column, int id) |
| |
new QModelIndex | CreateIndex (int row, int column, uint id) |
| |
new void | OnDataChanged (QModelIndex topLeft, QModelIndex bottomRight) |
| |
new bool | DecodeData (int row, int column, QModelIndex parent, QDataStream stream) |
new void | EncodeData (System.Collections.Generic.List< QModelIndex > indexes, QDataStream stream) |
new void | EndInsertColumns () |
| |
new void | EndInsertRows () |
| |
new void | EndMoveColumns () |
| |
new void | EndMoveRows () |
| |
new void | EndRemoveColumns () |
| |
new void | EndRemoveRows () |
| |
new void | EndResetModel () |
| |
new void | OnHeaderDataChanged (Qt.Orientation orientation, int first, int last) |
| |
new void | OnLayoutAboutToBeChanged () |
| |
new void | OnLayoutChanged () |
| |
new System.Collections.Generic.List < QModelIndex > | PersistentIndexList () |
| |
new void | Reset () |
| |
new void | ResetInternalData () |
| |
new void | SetRoleNames (System.Collections.Generic.Dictionary< System.Int32, QByteArray > roleNames) |
| |
Protected Member Functions inherited from QtCore.QObject | |
QObject (System.Type dummy) | |
virtual void | OnChildEvent (QChildEvent arg1) |
| |
virtual void | ConnectNotify (string signal) |
| |
virtual void | OnCustomEvent (QEvent arg1) |
| |
new void | OnDestroyed (QObject arg1=null) |
| |
virtual void | DisconnectNotify (string signal) |
| |
new int | Receivers (string signal) |
| |
new QObject | Sender () |
| |
new int | SenderSignalIndex () |
| |
virtual void | OnTimerEvent (QTimerEvent arg1) |
| |
Properties | |
Slot< QStandardItem > | ItemChanged |
| |
new QStandardItem | ItemPrototype [get, set] |
| |
new int | SortRole [get, set] |
| |
static new QMetaObject | StaticMetaObject [get] |
new IQStandardItemModelSignals | Emit [get] |
Properties inherited from QtCore.QAbstractItemModel | |
Slot< QModelIndex, QModelIndex > | DataChanged |
| |
Slot< Qt.Orientation, System.Int32, System.Int32 > | HeaderDataChanged |
| |
Slot | LayoutChanged |
| |
Slot | LayoutAboutToBeChanged |
| |
Slot< QModelIndex, System.Int32, System.Int32 > | RowsAboutToBeInserted |
Slot< QModelIndex, System.Int32, System.Int32 > | RowsInserted |
Slot< QModelIndex, System.Int32, System.Int32 > | RowsAboutToBeRemoved |
Slot< QModelIndex, System.Int32, System.Int32 > | RowsRemoved |
Slot< QModelIndex, System.Int32, System.Int32 > | ColumnsAboutToBeInserted |
Slot< QModelIndex, System.Int32, System.Int32 > | ColumnsInserted |
Slot< QModelIndex, System.Int32, System.Int32 > | ColumnsAboutToBeRemoved |
Slot< QModelIndex, System.Int32, System.Int32 > | ColumnsRemoved |
Slot | ModelAboutToBeReset |
Slot | ModelReset |
Slot< QModelIndex, System.Int32, System.Int32, QModelIndex, System.Int32 > | RowsAboutToBeMoved |
Slot< QModelIndex, System.Int32, System.Int32, QModelIndex, System.Int32 > | RowsMoved |
Slot< QModelIndex, System.Int32, System.Int32, QModelIndex, System.Int32 > | ColumnsAboutToBeMoved |
Slot< QModelIndex, System.Int32, System.Int32, QModelIndex, System.Int32 > | ColumnsMoved |
new Qt.DropAction | SupportedDragActions [get, set] |
| |
static new QMetaObject | StaticMetaObject [get] |
new IQAbstractItemModelSignals | Emit [get] |
Properties inherited from QtCore.QObject | |
virtual EventHandler < QEventArgs< QChildEvent > > | ChildEvent |
| |
virtual EventHandler < QEventArgs< QEvent > > | CustomEvent |
| |
virtual EventHandler < QEventArgs< QEvent > > | Event |
| |
virtual EventHandler < QEventArgs< QTimerEvent > > | TimerEvent |
| |
Slot< QObject > | DestroyedQObject |
Slot | Destroyed |
| |
new QObject | Parent [get, set] |
| |
virtual System.IntPtr | SmokeObject [get, set] |
new string | ObjectName [get, set] |
| |
static new QMetaObject | StaticMetaObject [get] |
| |
static new QMetaObject | StaticQtMetaObject [get] |
new IQObjectSignals | Emit [get] |
The QStandardItemModel class provides a generic model for storing custom data.
QStandardItemModel can be used as a repository for standard Qt data types. It is one of the Model/View Classes and is part of Qt's model/view framework.
QStandardItemModel provides a classic item-based approach to working with the model. The items in a QStandardItemModel are provided by QStandardItem.
QStandardItemModel implements the QAbstractItemModel interface, which means that the model can be used to provide data in any view that supports that interface (such as QListView, QTableView and QTreeView, and your own custom views). For performance and flexibility, you may want to subclass QAbstractItemModel to provide support for different kinds of data repositories. For example, the QDirModel(obsolete) provides a model interface to the underlying file system.
When you want a list or tree, you typically create an empty QStandardItemModel and use appendRow() to add items to the model, and item() to access an item. If your model represents a table, you typically pass the dimensions of the table to the QStandardItemModel constructor and use setItem() to position items into the table. You can also use setRowCount() and setColumnCount() to alter the dimensions of the model. To insert items, use insertRow() or insertColumn(), and to remove items, use removeRow() or removeColumn().
You can set the header labels of your model with setHorizontalHeaderLabels() and setVerticalHeaderLabels().
You can search for items in the model with findItems(), and sort the model by calling sort().
Call clear() to remove all items from the model.
An example usage of QStandardItemModel to create a table:
QStandardItemModel model(4, 4);
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 4; ++column) {
QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
model.setItem(row, column, item);
}
}
An example usage of QStandardItemModel to create a tree:
QStandardItemModel model;
QStandardItem *parentItem = model.invisibleRootItem();
for (int i = 0; i < 4; ++i) {
QStandardItem *item = new QStandardItem(QString("item %0").arg(i));
parentItem->appendRow(item);
parentItem = item;
}
After setting the model on a view, you typically want to react to user actions, such as an item being clicked. Since a QAbstractItemView provides QModelIndex-based signals and functions, you need a way to obtain the QStandardItem that corresponds to a given QModelIndex, and vice versa. itemFromIndex() and indexFromItem() provide this mapping. Typical usage of itemFromIndex() includes obtaining the item at the current index in a view, and obtaining the item that corresponds to an index carried by a QAbstractItemView signal, such as QAbstractItemView::clicked(). First you connect the view's signal to a slot in your class:
QTreeView *treeView = new QTreeView(this);
treeView->setModel(myStandardItemModel);
connect(treeView, SIGNAL(clicked(QModelIndex)),
this, SLOT(clicked(QModelIndex)));
When you receive the signal, you call itemFromIndex() on the given model index to get a pointer to the item:
void MyWidget::clicked(const QModelIndex &index)
{
QStandardItem *item = myStandardItemModel->itemFromIndex(index);
// Do stuff with the item ...
}
Conversely, you must obtain the QModelIndex of an item when you want to invoke a model/view function that takes an index as argument. You can obtain the index either by using the model's indexFromItem() function, or, equivalently, by calling QStandardItem::index():
treeView->scrollTo(item->index());
You are, of course, not required to use the item-based approach; you could instead rely entirely on the QAbstractItemModel interface when working with the model, or use a combination of the two as appropriate.
See also QStandardItem, Model/View Programming, QAbstractItemModel, Simple Tree Model example, and Item View Convenience Classes.
|
protected |
QtGui.QStandardItemModel.QStandardItemModel | ( | QObject | parent = null | ) |
Constructs a new item model with the given parent.
QtGui.QStandardItemModel.QStandardItemModel | ( | int | rows, |
int | columns, | ||
QObject | parent = null |
||
) |
Constructs a new item model that initially has rows rows and columns columns, and that has the given parent.
new void QtGui.QStandardItemModel.AppendColumn | ( | System.Collections.Generic.List< QStandardItem > | items | ) |
Appends a column containing items. If necessary, the row count is increased to the size of items.
This function was introduced in Qt 4.2.
See also insertColumn() and appendRow().
new void QtGui.QStandardItemModel.AppendRow | ( | QStandardItem | item | ) |
This is an overloaded function.
When building a list or a tree that has only one column, this function provides a convenient way to append a single new item.
This function was introduced in Qt 4.2.
new void QtGui.QStandardItemModel.AppendRow | ( | System.Collections.Generic.List< QStandardItem > | items | ) |
Appends a row containing items. If necessary, the column count is increased to the size of items.
This function was introduced in Qt 4.2.
See also insertRow() and appendColumn().
new void QtGui.QStandardItemModel.Clear | ( | ) |
Removes all items (including header items) from the model and sets the number of rows and columns to zero.
See also removeColumns() and removeRows().
new int QtGui.QStandardItemModel.ColumnCount | ( | ) |
Reimplemented from QAbstractItemModel::columnCount().
See also setColumnCount().
override int QtGui.QStandardItemModel.ColumnCount | ( | QModelIndex | parent | ) |
Reimplemented from QAbstractItemModel::columnCount().
See also setColumnCount().
|
virtual |
Reimplemented from QtCore.QAbstractItemModel.
|
virtual |
Reimplemented from QAbstractItemModel::data().
See also setData().
Implements QtCore.QAbstractItemModel.
new void QtGui.QStandardItemModel.Dispose | ( | ) |
|
virtual |
Reimplemented from QAbstractItemModel::dropMimeData().
Reimplemented from QtCore.QAbstractItemModel.
new System.Collections.Generic.List<QStandardItem> QtGui.QStandardItemModel.FindItems | ( | string | text, |
Qt.MatchFlag | flags = Qt.MatchFlag.MatchExactly , |
||
int | column = 0 |
||
) |
Returns a list of items that match the given text, using the given flags, in the given column.
This function was introduced in Qt 4.2.
|
virtual |
Reimplemented from QAbstractItemModel::flags().
Reimplemented from QtCore.QAbstractItemModel.
new bool QtGui.QStandardItemModel.HasChildren | ( | ) |
Reimplemented from QAbstractItemModel::hasChildren().
|
virtual |
Reimplemented from QAbstractItemModel::hasChildren().
Reimplemented from QtCore.QAbstractItemModel.
|
virtual |
Reimplemented from QAbstractItemModel::headerData().
See also setHeaderData().
Reimplemented from QtCore.QAbstractItemModel.
new QStandardItem QtGui.QStandardItemModel.HorizontalHeaderItem | ( | int | column | ) |
Returns the horizontal header item for column if one has been set; otherwise returns 0.
This function was introduced in Qt 4.2.
See also setHorizontalHeaderItem() and verticalHeaderItem().
new QModelIndex QtGui.QStandardItemModel.Index | ( | int | row, |
int | column | ||
) |
Reimplemented from QAbstractItemModel::index().
|
virtual |
Reimplemented from QAbstractItemModel::index().
Implements QtCore.QAbstractItemModel.
new QModelIndex QtGui.QStandardItemModel.IndexFromItem | ( | QStandardItem | item | ) |
Returns the QModelIndex associated with the given item.
Use this function when you want to perform an operation that requires the QModelIndex of the item, such as QAbstractItemView::scrollTo(). QStandardItem::index() is provided as convenience; it is equivalent to calling this function.
This function was introduced in Qt 4.2.
See also itemFromIndex() and QStandardItem::index().
new bool QtGui.QStandardItemModel.InsertColumn | ( | int | column | ) |
Inserts a column at column containing items. If necessary, the row count is increased to the size of items.
This function was introduced in Qt 4.2.
See also takeColumn(), appendColumn(), and insertRow().
new bool QtGui.QStandardItemModel.InsertColumn | ( | int | column, |
QModelIndex | parent | ||
) |
Inserts a column at column containing items. If necessary, the row count is increased to the size of items.
This function was introduced in Qt 4.2.
See also takeColumn(), appendColumn(), and insertRow().
new void QtGui.QStandardItemModel.InsertColumn | ( | int | column, |
System.Collections.Generic.List< QStandardItem > | items | ||
) |
Inserts a column at column containing items. If necessary, the row count is increased to the size of items.
This function was introduced in Qt 4.2.
See also takeColumn(), appendColumn(), and insertRow().
new bool QtGui.QStandardItemModel.InsertColumns | ( | int | column, |
int | count | ||
) |
Reimplemented from QAbstractItemModel::insertColumns().
|
virtual |
Reimplemented from QAbstractItemModel::insertColumns().
Reimplemented from QtCore.QAbstractItemModel.
new bool QtGui.QStandardItemModel.InsertRow | ( | int | row | ) |
Inserts a row at row containing items. If necessary, the column count is increased to the size of items.
This function was introduced in Qt 4.2.
See also takeRow(), appendRow(), and insertColumn().
new void QtGui.QStandardItemModel.InsertRow | ( | int | row, |
QStandardItem | item | ||
) |
This is an overloaded function.
Inserts a row at row containing item.
When building a list or a tree that has only one column, this function provides a convenient way to append a single new item.
This function was introduced in Qt 4.2.
new bool QtGui.QStandardItemModel.InsertRow | ( | int | row, |
QModelIndex | parent | ||
) |
Inserts a row at row containing items. If necessary, the column count is increased to the size of items.
This function was introduced in Qt 4.2.
See also takeRow(), appendRow(), and insertColumn().
new void QtGui.QStandardItemModel.InsertRow | ( | int | row, |
System.Collections.Generic.List< QStandardItem > | items | ||
) |
Inserts a row at row containing items. If necessary, the column count is increased to the size of items.
This function was introduced in Qt 4.2.
See also takeRow(), appendRow(), and insertColumn().
new bool QtGui.QStandardItemModel.InsertRows | ( | int | row, |
int | count | ||
) |
Reimplemented from QAbstractItemModel::insertRows().
|
virtual |
Reimplemented from QAbstractItemModel::insertRows().
Reimplemented from QtCore.QAbstractItemModel.
new QStandardItem QtGui.QStandardItemModel.InvisibleRootItem | ( | ) |
Returns the model's invisible root item.
The invisible root item provides access to the model's top-level items through the QStandardItem API, making it possible to write functions that can treat top-level items and their children in a uniform way; for example, recursive functions involving a tree model.
Note: Calling index() on the QStandardItem object retrieved from this function is not valid.
This function was introduced in Qt 4.2.
new QStandardItem QtGui.QStandardItemModel.Item | ( | int | row, |
int | column = 0 |
||
) |
Returns the item for the given row and column if one has been set; otherwise returns 0.
This function was introduced in Qt 4.2.
See also setItem(), takeItem(), and itemFromIndex().
|
virtual |
Reimplemented from QAbstractItemModel::itemData().
See also setItemData().
Reimplemented from QtCore.QAbstractItemModel.
new QStandardItem QtGui.QStandardItemModel.ItemFromIndex | ( | QModelIndex | index | ) |
Returns a pointer to the QStandardItem associated with the given index.
Calling this function is typically the initial step when processing QModelIndex-based signals from a view, such as QAbstractItemView::activated(). In your slot, you call itemFromIndex(), with the QModelIndex carried by the signal as argument, to obtain a pointer to the corresponding QStandardItem.
Note that this function will lazily create an item for the index (using itemPrototype()), and set it in the parent item's child table, if no item already exists at that index.
If index is an invalid index, this function returns 0.
This function was introduced in Qt 4.2.
See also indexFromItem().
|
virtual |
Reimplemented from QAbstractItemModel::mimeData().
Reimplemented from QtCore.QAbstractItemModel.
|
virtual |
Reimplemented from QAbstractItemModel::mimeTypes().
Reimplemented from QtCore.QAbstractItemModel.
|
protected |
This signal is emitted whenever the data of item has changed.
This function was introduced in Qt 4.2.
new QObject QtGui.QStandardItemModel.parent | ( | ) |
Reimplemented from QAbstractItemModel::parent().
|
virtual |
Reimplemented from QAbstractItemModel::parent().
Implements QtCore.QAbstractItemModel.
new bool QtGui.QStandardItemModel.RemoveColumns | ( | int | column, |
int | count | ||
) |
Reimplemented from QAbstractItemModel::removeColumns().
|
virtual |
Reimplemented from QAbstractItemModel::removeColumns().
Reimplemented from QtCore.QAbstractItemModel.
new bool QtGui.QStandardItemModel.RemoveRows | ( | int | row, |
int | count | ||
) |
Reimplemented from QAbstractItemModel::removeRows().
|
virtual |
Reimplemented from QAbstractItemModel::removeRows().
Reimplemented from QtCore.QAbstractItemModel.
new int QtGui.QStandardItemModel.RowCount | ( | ) |
Reimplemented from QAbstractItemModel::rowCount().
See also setRowCount().
|
virtual |
Reimplemented from QAbstractItemModel::rowCount().
See also setRowCount().
Implements QtCore.QAbstractItemModel.
new void QtGui.QStandardItemModel.SetColumnCount | ( | int | columns | ) |
Sets the number of columns in this model to columns. If this is less than columnCount(), the data in the unwanted columns is discarded.
This function was introduced in Qt 4.2.
See also columnCount() and setRowCount().
|
virtual |
Reimplemented from QAbstractItemModel::setData().
See also data().
Reimplemented from QtCore.QAbstractItemModel.
|
virtual |
Reimplemented from QAbstractItemModel::setHeaderData().
See also headerData().
Reimplemented from QtCore.QAbstractItemModel.
new void QtGui.QStandardItemModel.SetHorizontalHeaderItem | ( | int | column, |
QStandardItem | item | ||
) |
Sets the horizontal header item for column to item. The model takes ownership of the item. If necessary, the column count is increased to fit the item. The previous header item (if there was one) is deleted.
This function was introduced in Qt 4.2.
See also horizontalHeaderItem(), setHorizontalHeaderLabels(), and setVerticalHeaderItem().
new void QtGui.QStandardItemModel.SetHorizontalHeaderLabels | ( | System.Collections.Generic.List< string > | labels | ) |
Sets the horizontal header labels using labels. If necessary, the column count is increased to the size of labels.
This function was introduced in Qt 4.2.
See also setHorizontalHeaderItem().
new void QtGui.QStandardItemModel.SetItem | ( | int | row, |
QStandardItem | item | ||
) |
This is an overloaded function.
new void QtGui.QStandardItemModel.SetItem | ( | int | row, |
int | column, | ||
QStandardItem | item | ||
) |
Sets the item for the given row and column to item. The model takes ownership of the item. If necessary, the row count and column count are increased to fit the item. The previous item at the given location (if there was one) is deleted.
This function was introduced in Qt 4.2.
See also item().
|
virtual |
Reimplemented from QAbstractItemModel::setItemData().
See also itemData().
Reimplemented from QtCore.QAbstractItemModel.
new void QtGui.QStandardItemModel.SetRowCount | ( | int | rows | ) |
Sets the number of rows in this model to rows. If this is less than rowCount(), the data in the unwanted rows is discarded.
This function was introduced in Qt 4.2.
See also rowCount() and setColumnCount().
new void QtGui.QStandardItemModel.SetVerticalHeaderItem | ( | int | row, |
QStandardItem | item | ||
) |
Sets the vertical header item for row to item. The model takes ownership of the item. If necessary, the row count is increased to fit the item. The previous header item (if there was one) is deleted.
This function was introduced in Qt 4.2.
See also verticalHeaderItem(), setVerticalHeaderLabels(), and setHorizontalHeaderItem().
new void QtGui.QStandardItemModel.SetVerticalHeaderLabels | ( | System.Collections.Generic.List< string > | labels | ) |
Sets the vertical header labels using labels. If necessary, the row count is increased to the size of labels.
This function was introduced in Qt 4.2.
See also setVerticalHeaderItem().
|
virtual |
Reimplemented from QAbstractItemModel::sort().
Reimplemented from QtCore.QAbstractItemModel.
|
virtual |
Reimplemented from QAbstractItemModel::supportedDropActions().
QStandardItemModel supports both copy and move.
Reimplemented from QtCore.QAbstractItemModel.
new System.Collections.Generic.List<QStandardItem> QtGui.QStandardItemModel.TakeColumn | ( | int | column | ) |
Removes the given column without deleting the column items, and returns a list of pointers to the removed items. The model releases ownership of the items. For items in the column that have not been set, the corresponding pointers in the list will be 0.
This function was introduced in Qt 4.2.
See also takeRow().
new QStandardItem QtGui.QStandardItemModel.TakeHorizontalHeaderItem | ( | int | column | ) |
Removes the horizontal header item at column from the header without deleting it, and returns a pointer to the item. The model releases ownership of the item.
This function was introduced in Qt 4.2.
See also horizontalHeaderItem() and takeVerticalHeaderItem().
new QStandardItem QtGui.QStandardItemModel.TakeItem | ( | int | row, |
int | column = 0 |
||
) |
Removes the item at (row, column) without deleting it. The model releases ownership of the item.
This function was introduced in Qt 4.2.
See also item(), takeRow(), and takeColumn().
new System.Collections.Generic.List<QStandardItem> QtGui.QStandardItemModel.TakeRow | ( | int | row | ) |
Removes the given row without deleting the row items, and returns a list of pointers to the removed items. The model releases ownership of the items. For items in the row that have not been set, the corresponding pointers in the list will be 0.
This function was introduced in Qt 4.2.
See also takeColumn().
new QStandardItem QtGui.QStandardItemModel.TakeVerticalHeaderItem | ( | int | row | ) |
Removes the vertical header item at row from the header without deleting it, and returns a pointer to the item. The model releases ownership of the item.
This function was introduced in Qt 4.2.
See also verticalHeaderItem() and takeHorizontalHeaderItem().
|
static |
|
static |
|
static |
|
static |
new QStandardItem QtGui.QStandardItemModel.VerticalHeaderItem | ( | int | row | ) |
Returns the vertical header item for row row if one has been set; otherwise returns 0.
This function was introduced in Qt 4.2.
See also setVerticalHeaderItem() and horizontalHeaderItem().
|
getprotected |
|
addremove |
This signal is emitted whenever the data of item has changed.
This function was introduced in Qt 4.2.
|
getset |
Returns the item prototype used by the model. The model uses the item prototype as an item factory when it needs to construct new items on demand (for instance, when a view or item delegate calls setData()).
This function was introduced in Qt 4.2.
Sets the item prototype for the model to the specified item. The model takes ownership of the prototype.
The item prototype acts as a QStandardItem factory, by relying on the QStandardItem::clone() function. To provide your own prototype, subclass QStandardItem, reimplement QStandardItem::clone() and set the prototype to be an instance of your custom class. Whenever QStandardItemModel needs to create an item on demand (for instance, when a view or item delegate calls setData())), the new items will be instances of your custom class.
This function was introduced in Qt 4.2.
|
getset |
This property holds the item role that is used to query the model's data when sorting items.
The default value is Qt::DisplayRole.
This property was introduced in Qt 4.2.
|
staticget |