Qyoto
4.0.5
Qyoto is a C# language binding for Qt
|
The QSqlTableModel class provides an editable data model for a single database table. More...
Public Types | |
enum | EditStrategy { OnFieldChange = 0, OnManualSubmit = 2, OnRowChange = 1 } |
More... | |
Public Member Functions | |
QSqlTableModel (QObject parent=null) | |
| |
QSqlTableModel (QObject parent, QSqlDatabase db) | |
| |
override void | CreateProxy () |
override void | Clear () |
| |
override object | Data (QModelIndex idx, int role=(int) Qt.ItemDataRole.DisplayRole) |
| |
new QSqlDatabase | Database () |
| |
new int | FieldIndex (string fieldName) |
| |
override Qt.ItemFlag | Flags (QModelIndex index) |
| |
override object | HeaderData (int section, Qt.Orientation orientation, int role=(int) Qt.ItemDataRole.DisplayRole) |
| |
new bool | InsertRecord (int row, QSqlRecord record) |
| |
new bool | InsertRows (int row, int count) |
| |
override bool | InsertRows (int row, int count, QModelIndex parent) |
| |
new bool | IsDirty (QModelIndex index) |
| |
new QSqlIndex | PrimaryKey () |
| |
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) |
| |
override void | Revert () |
| |
new void | RevertAll () |
| |
virtual void | RevertRow (int row) |
| |
new int | RowCount () |
| |
override int | RowCount (QModelIndex parent) |
| |
virtual bool | Select () |
| |
override bool | SetData (QModelIndex index, object value, int role=(int) Qt.ItemDataRole.EditRole) |
| |
new bool | SetRecord (int row, QSqlRecord record) |
| |
virtual void | SetSort (int column, Qt.SortOrder order) |
| |
virtual void | SetTable (string tableName) |
| |
override void | Sort (int column, Qt.SortOrder order) |
| |
override bool | Submit () |
| |
new bool | SubmitAll () |
| |
new string | TableName () |
| |
new void | Dispose () |
Public Member Functions inherited from QtSql.QSqlQueryModel | |
QSqlQueryModel (QObject parent=null) | |
| |
new bool | CanFetchMore () |
| |
override bool | CanFetchMore (QModelIndex parent) |
| |
new int | ColumnCount () |
| |
override int | ColumnCount (QModelIndex parent) |
| |
new void | FetchMore () |
| |
override void | FetchMore (QModelIndex parent) |
| |
new bool | InsertColumns (int column, int count) |
| |
override bool | InsertColumns (int column, int count, QModelIndex parent) |
| |
new QSqlError | LastError () |
| |
new QSqlRecord | Record () |
| |
new QSqlRecord | Record (int row) |
| |
new bool | RemoveColumns (int column, int count) |
| |
new int | RowCount () |
| |
override bool | SetHeaderData (int section, Qt.Orientation orientation, object value, int role=(int) Qt.ItemDataRole.EditRole) |
| |
new void | SetQuery (string query) |
| |
new void | SetQuery (string query, QSqlDatabase db) |
| |
new void | Dispose () |
Public Member Functions inherited from QtCore.QAbstractTableModel | |
QAbstractTableModel (QObject parent=null) | |
| |
override bool | DropMimeData (QMimeData data, Qt.DropAction action, int row, int column, QModelIndex parent) |
| |
new QModelIndex | Index (int row, int column) |
| |
override QModelIndex | Index (int row, int column, QModelIndex parent) |
| |
new void | Dispose () |
Public Member Functions inherited from QtCore.QAbstractItemModel | |
QAbstractItemModel (QObject parent=null) | |
| |
virtual QModelIndex | Buddy (QModelIndex index) |
| |
new bool | HasChildren () |
| |
virtual bool | HasChildren (QModelIndex parent) |
| |
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.Dictionary < System.Int32, System.Object > | ItemData (QModelIndex index) |
| |
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) |
| |
virtual QMimeData | MimeData (System.Collections.Generic.List< QModelIndex > indexes) |
| |
virtual System.Collections.Generic.List < string > | MimeTypes () |
| |
new QObject | Parent () |
| |
abstract QModelIndex | Parent (QModelIndex child) |
| |
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) |
| |
new System.Collections.Generic.Dictionary < System.Int32, QByteArray > | RoleNames () |
| |
new int | RowCount () |
| |
virtual bool | SetItemData (QModelIndex index, System.Collections.Generic.Dictionary< System.Int32, System.Object > roles) |
| |
new QModelIndex | Sibling (int row, int column, QModelIndex idx) |
| |
virtual QSize | Span (QModelIndex index) |
| |
virtual Qt.DropAction | SupportedDropActions () |
| |
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 QtSql.QSqlQueryModel | |
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.QAbstractTableModel | |
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 | |
QSqlTableModel (System.Type dummy) | |
new void | OnBeforeDelete (int row) |
| |
new void | OnBeforeInsert (QSqlRecord record) |
| |
new void | OnBeforeUpdate (int row, QSqlRecord record) |
| |
virtual bool | DeleteRowFromTable (int row) |
| |
new QModelIndex | IndexInQuery (QModelIndex item) |
| |
virtual bool | InsertRowIntoTable (QSqlRecord values) |
| |
virtual string | OrderByClause () |
| |
new void | OnPrimeInsert (int row, QSqlRecord record) |
| |
virtual string | SelectStatement () |
| |
new void | SetPrimaryKey (QSqlIndex key) |
| |
new void | SetQuery (QSqlQuery query) |
| |
virtual bool | UpdateRowInTable (int row, QSqlRecord values) |
| |
Protected Member Functions inherited from QtSql.QSqlQueryModel | |
QSqlQueryModel (System.Type dummy) | |
new QModelIndex | IndexInQuery (QModelIndex item) |
| |
virtual void | QueryChange () |
| |
new void | SetLastError (QSqlError error) |
| |
Protected Member Functions inherited from QtCore.QAbstractTableModel | |
QAbstractTableModel (System.Type dummy) | |
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< System.Int32, QSqlRecord > | PrimeInsert |
| |
Slot< QSqlRecord > | BeforeInsert |
| |
Slot< System.Int32, QSqlRecord > | BeforeUpdate |
| |
Slot< System.Int32 > | BeforeDelete |
| |
virtual QSqlTableModel.EditStrategy | editStrategy [get, set] |
| |
virtual string | Filter [get, set] |
| |
static new QMetaObject | StaticMetaObject [get] |
new IQSqlTableModelSignals | Emit [get] |
Properties inherited from QtSql.QSqlQueryModel | |
new QSqlQuery | Query [get, set] |
| |
static new QMetaObject | StaticMetaObject [get] |
new IQSqlQueryModelSignals | Emit [get] |
Properties inherited from QtCore.QAbstractTableModel | |
static new QMetaObject | StaticMetaObject [get] |
new IQAbstractTableModelSignals | 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] |
Additional Inherited Members | |
Protected Attributes inherited from QtCore.QObject | |
object | Q_EMIT = null |
SmokeInvocation | interceptor |
readonly List< QEventHandler > | eventFilters = new List<QEventHandler>() |
The QSqlTableModel class provides an editable data model for a single database table.
QSqlTableModel is a high-level interface for reading and writing database records from a single table. It is build on top of the lower-level QSqlQuery and can be used to provide data to view classes such as QTableView. For example:
QSqlTableModel *model = new QSqlTableModel(parentObject, database);
model->setTable("employee");
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->select();
model->setHeaderData(0, Qt::Horizontal, tr("Name"));
model->setHeaderData(1, Qt::Horizontal, tr("Salary"));
QTableView *view = new QTableView;
view->setModel(model);
view->hideColumn(0); // don't show the ID
view->show();
We set the SQL table's name and the edit strategy, then we set up the labels displayed in the view header. The edit strategy dictates when the changes done by the user in the view are actually applied to the database. The possible values are OnFieldChange, OnRowChange, and OnManualSubmit.
QSqlTableModel can also be used to access a database programmatically, without binding it to a view:
QSqlQueryModel model;
model.setQuery("SELECT * FROM employee");
int salary = model.record(4).value("salary").toInt();
The code snippet above extracts the salary field from record 4 in the result set of the query SELECT * from employee.
It is possible to set filters using setFilter(), or modify the sort order using setSort(). At the end, you must call select() to populate the model with data.
The sql/tablemodel example illustrates how to use QSqlTableModel as the data source for a QTableView.
QSqlTableModel provides no direct support for foreign keys. Use the QSqlRelationalTableModel and QSqlRelationalDelegate if you want to resolve foreign keys.
See also QSqlRelationalTableModel, QSqlQuery, Model/View Programming, Table Model Example, and Cached Table Example.
This enum type describes which strategy to choose when editing values in the database.
Note: To prevent inserting only partly initialized rows into the database, OnFieldChange will behave like OnRowChange for newly inserted rows.
See also setEditStrategy().
|
protected |
QtSql.QSqlTableModel.QSqlTableModel | ( | QObject | parent = null | ) |
Creates an empty QSqlTableModel and sets the parent to parent and the database connection to db. If db is not valid, the default database connection will be used.
The default edit strategy is OnRowChange.
QtSql.QSqlTableModel.QSqlTableModel | ( | QObject | parent, |
QSqlDatabase | db | ||
) |
Creates an empty QSqlTableModel and sets the parent to parent and the database connection to db. If db is not valid, the default database connection will be used.
The default edit strategy is OnRowChange.
|
virtual |
Reimplemented from QSqlQueryModel::clear().
Reimplemented from QtSql.QSqlQueryModel.
|
virtual |
Reimplemented from QtSql.QSqlQueryModel.
|
virtual |
Reimplemented from QAbstractItemModel::data().
See also setData().
Reimplemented from QtSql.QSqlQueryModel.
new QSqlDatabase QtSql.QSqlTableModel.Database | ( | ) |
Returns a pointer to the used QSqlDatabase or 0 if no database was set.
|
protectedvirtual |
Deletes the given row from the currently active database table.
This is a low-level method that operates directly on the database and should not be called directly. Use removeRow() or removeRows() to delete values. The model will decide depending on its edit strategy when to modify the database.
Returns true if the row was deleted; otherwise returns false.
See also removeRow() and removeRows().
new void QtSql.QSqlTableModel.Dispose | ( | ) |
new int QtSql.QSqlTableModel.FieldIndex | ( | string | fieldName | ) |
Returns the index of the field fieldName, or -1 if no corresponding field exists in the model.
|
virtual |
Reimplemented from QAbstractItemModel::flags().
Reimplemented from QtCore.QAbstractItemModel.
|
virtual |
Reimplemented from QAbstractItemModel::headerData().
Reimplemented from QtSql.QSqlQueryModel.
|
protected |
Returns the index of the value in the database result set for the given item in the model.
The return value is identical to item if no columns or rows have been inserted, removed, or moved around.
Returns an invalid model index if item is out of bounds or if item does not point to a value in the result set.
See also QSqlQueryModel::indexInQuery().
new bool QtSql.QSqlTableModel.InsertRecord | ( | int | row, |
QSqlRecord | record | ||
) |
Inserts the record after row. If row is negative, the record will be appended to the end. Calls insertRows() and setRecord() internally.
Returns true if the row could be inserted, otherwise false.
See also insertRows() and removeRows().
|
protectedvirtual |
Inserts the values values into the currently active database table.
This is a low-level method that operates directly on the database and should not be called directly. Use insertRow() and setData() to insert values. The model will decide depending on its edit strategy when to modify the database.
Returns true if the values could be inserted, otherwise false. Error information can be retrieved with lastError().
See also lastError(), insertRow(), and insertRows().
Reimplemented in QtSql.QSqlRelationalTableModel.
new bool QtSql.QSqlTableModel.InsertRows | ( | int | row, |
int | count | ||
) |
Reimplemented from QAbstractItemModel::insertRows().
Inserts count empty rows at position row. Note that parent must be invalid, since this model does not support parent-child relations.
Only one row at a time can be inserted when using the OnFieldChange or OnRowChange update strategies.
The primeInsert() signal will be emitted for each new row. Connect to it if you want to initialize the new row with default values.
Returns false if the parameters are out of bounds; otherwise returns true.
See also primeInsert() and insertRecord().
|
virtual |
Reimplemented from QAbstractItemModel::insertRows().
Inserts count empty rows at position row. Note that parent must be invalid, since this model does not support parent-child relations.
Only one row at a time can be inserted when using the OnFieldChange or OnRowChange update strategies.
The primeInsert() signal will be emitted for each new row. Connect to it if you want to initialize the new row with default values.
Returns false if the parameters are out of bounds; otherwise returns true.
See also primeInsert() and insertRecord().
Reimplemented from QtCore.QAbstractItemModel.
new bool QtSql.QSqlTableModel.IsDirty | ( | QModelIndex | index | ) |
Returns true if the value at the index index is dirty, otherwise false. Dirty values are values that were modified in the model but not yet written into the database.
If index is invalid or points to a non-existing row, false is returned.
|
protected |
This signal is emitted by deleteRowFromTable() before the row is deleted from the currently active database table.
|
protected |
This signal is emitted by insertRowIntoTable() before a new row is inserted into the currently active database table. The values that are about to be inserted are stored in record and can be modified before they will be inserted.
|
protected |
This signal is emitted by updateRowInTable() before the row is updated in the currently active database table with the values from record.
Note that only values that are marked as generated will be updated. The generated flag can be set with QSqlRecord::setGenerated() and checked with QSqlRecord::isGenerated().
See also QSqlRecord::isGenerated().
|
protected |
This signal is emitted by insertRows(), when an insertion is initiated in the given row of the currently active database table. The record parameter can be written to (since it is a reference), for example to populate some fields with default values.
|
protectedvirtual |
Returns an SQL ORDER BY clause based on the currently set sort order.
See also setSort() and selectStatement().
Reimplemented in QtSql.QSqlRelationalTableModel.
new QSqlIndex QtSql.QSqlTableModel.PrimaryKey | ( | ) |
Returns the primary key for the current table, or an empty QSqlIndex if the table is not set or has no primary key.
See also setTable(), setPrimaryKey(), and QSqlDatabase::primaryIndex().
new bool QtSql.QSqlTableModel.RemoveColumns | ( | int | column, |
int | count | ||
) |
Reimplemented from QAbstractItemModel::removeColumns().
Removes count columns from the parent model, starting at index column.
Returns if the columns were successfully removed; otherwise returns false.
See also removeRows().
|
virtual |
Reimplemented from QAbstractItemModel::removeColumns().
Removes count columns from the parent model, starting at index column.
Returns if the columns were successfully removed; otherwise returns false.
See also removeRows().
Reimplemented from QtSql.QSqlQueryModel.
new bool QtSql.QSqlTableModel.RemoveRows | ( | int | row, |
int | count | ||
) |
Reimplemented from QAbstractItemModel::removeRows().
Removes count rows starting at row. Since this model does not support hierarchical structures, parent must be an invalid model index.
Emits the beforeDelete() signal before a row is deleted. When the edit strategy is OnManualSubmit signal emission is delayed until submitAll() is called.
Returns true if all rows could be removed; otherwise returns false. Detailed error information can be retrieved using lastError().
See also removeColumns() and insertRows().
|
virtual |
Reimplemented from QAbstractItemModel::removeRows().
Removes count rows starting at row. Since this model does not support hierarchical structures, parent must be an invalid model index.
Emits the beforeDelete() signal before a row is deleted. When the edit strategy is OnManualSubmit signal emission is delayed until submitAll() is called.
Returns true if all rows could be removed; otherwise returns false. Detailed error information can be retrieved using lastError().
See also removeColumns() and insertRows().
Reimplemented from QtCore.QAbstractItemModel.
|
virtual |
Reimplemented from QAbstractItemModel::revert().
This reimplemented slot is called by the item delegates when the user canceled editing the current row.
Reverts the changes if the model's strategy is set to OnRowChange. Does nothing for the other edit strategies.
Use revertAll() to revert all pending changes for the OnManualSubmit strategy or revertRow() to revert a specific row.
See also submit(), submitAll(), revertRow(), and revertAll().
Reimplemented from QtCore.QAbstractItemModel.
new void QtSql.QSqlTableModel.RevertAll | ( | ) |
Reverts all pending changes.
See also revert(), revertRow(), and submitAll().
|
virtual |
Reverts all changes for the specified row.
See also revert(), revertAll(), submit(), and submitAll().
Reimplemented in QtSql.QSqlRelationalTableModel.
new int QtSql.QSqlTableModel.RowCount | ( | ) |
Reimplemented from QAbstractItemModel::rowCount().
|
virtual |
Reimplemented from QAbstractItemModel::rowCount().
Reimplemented from QtSql.QSqlQueryModel.
|
virtual |
Populates the model with data from the table that was set via setTable(), using the specified filter and sort condition, and returns true if successful; otherwise returns false.
Note: Calling select() will revert any unsubmitted changes and remove any inserted columns.
See also setTable(), setFilter(), and selectStatement().
Reimplemented in QtSql.QSqlRelationalTableModel.
|
protectedvirtual |
Returns the SQL SELECT statement used internally to populate the model. The statement includes the filter and the ORDER BY clause.
See also filter() and orderByClause().
Reimplemented in QtSql.QSqlRelationalTableModel.
|
virtual |
Reimplemented from QAbstractItemModel::setData().
Sets the data for the item index for the role role to value. Depending on the edit strategy, the value might be applied to the database at once or cached in the model.
Returns true if the value could be set or false on error, for example if index is out of bounds.
See also editStrategy(), data(), submit(), submitAll(), and revertRow().
Reimplemented from QtCore.QAbstractItemModel.
|
protected |
Protected method that allows subclasses to set the primary key to key.
Normally, the primary index is set automatically whenever you call setTable().
See also primaryKey() and QSqlDatabase::primaryIndex().
|
protected |
This function simply calls QSqlQueryModel::setQuery(query). You should normally not call it on a QSqlTableModel. Instead, use setTable(), setSort(), setFilter(), etc., to set up the query.
See also selectStatement().
new bool QtSql.QSqlTableModel.SetRecord | ( | int | row, |
QSqlRecord | record | ||
) |
Sets the values at the specified row to the values of record. Returns true if all the values could be set; otherwise returns false.
See also record().
|
virtual |
Sets the sort order for column to order. This does not affect the current data, to refresh the data using the new sort order, call select().
See also sort(), select(), and orderByClause().
|
virtual |
Sets the database table on which the model operates to tableName. Does not select data from the table, but fetches its field information.
To populate the model with the table's data, call select().
Error information can be retrieved with lastError().
See also select(), setFilter(), and lastError().
Reimplemented in QtSql.QSqlRelationalTableModel.
|
virtual |
Reimplemented from QAbstractItemModel::sort().
Sorts the data by column with the sort order order. This will immediately select data, use setSort() to set a sort order without populating the model with data.
See also setSort(), select(), and orderByClause().
Reimplemented from QtCore.QAbstractItemModel.
|
virtual |
Reimplemented from QAbstractItemModel::submit().
This reimplemented slot is called by the item delegates when the user stopped editing the current row.
Submits the currently edited row if the model's strategy is set to OnRowChange or OnFieldChange. Does nothing for the OnManualSubmit strategy.
Use submitAll() to submit all pending changes for the OnManualSubmit strategy.
Returns true on success; otherwise returns false. Use lastError() to query detailed error information.
On success the model will be repopulated. Any views presenting it will lose their selections.
See also revert(), revertRow(), submitAll(), revertAll(), and lastError().
Reimplemented from QtCore.QAbstractItemModel.
new bool QtSql.QSqlTableModel.SubmitAll | ( | ) |
Submits all pending changes and returns true on success. Returns false on error, detailed error information can be obtained with lastError().
On success the model will be repopulated. Any views presenting it will lose their selections.
Note: In OnManualSubmit mode, already submitted changes won't be cleared from the cache when submitAll() fails. This allows transactions to be rolled back and resubmitted again without losing data.
See also revertAll() and lastError().
new string QtSql.QSqlTableModel.TableName | ( | ) |
Returns the name of the currently selected table.
|
static |
|
static |
|
static |
|
static |
|
protectedvirtual |
Updates the given row in the currently active database table with the specified values. Returns true if successful; otherwise returns false.
This is a low-level method that operates directly on the database and should not be called directly. Use setData() to update values. The model will decide depending on its edit strategy when to modify the database.
Note that only values that have the generated-flag set are updated. The generated-flag can be set with QSqlRecord::setGenerated() and tested with QSqlRecord::isGenerated().
See also QSqlRecord::isGenerated() and setData().
Reimplemented in QtSql.QSqlRelationalTableModel.
|
addremove |
This signal is emitted by deleteRowFromTable() before the row is deleted from the currently active database table.
|
addremove |
This signal is emitted by insertRowIntoTable() before a new row is inserted into the currently active database table. The values that are about to be inserted are stored in record and can be modified before they will be inserted.
|
addremove |
This signal is emitted by updateRowInTable() before the row is updated in the currently active database table with the values from record.
Note that only values that are marked as generated will be updated. The generated flag can be set with QSqlRecord::setGenerated() and checked with QSqlRecord::isGenerated().
See also QSqlRecord::isGenerated().
|
getset |
Returns the current edit strategy.
Sets the strategy for editing values in the database to strategy.
This will revert any pending changes.
|
getprotected |
|
getset |
Returns the currently set filter.
Sets the current filter to filter.
The filter is a SQL WHERE clause without the keyword WHERE (for example, name='Josephine').
If the model is already populated with data from a database, the model re-selects it with the new filter. Otherwise, the filter will be applied the next time select() is called.
|
addremove |
This signal is emitted by insertRows(), when an insertion is initiated in the given row of the currently active database table. The record parameter can be written to (since it is a reference), for example to populate some fields with default values.
|
staticget |