QmlSqlQueryModel QML Type
The QmlSqlQueryModel object provides a read-only data model for SQL result sets. More...
Import Statement: | import QmlSql 1.0 |
Properties
- connectionName : string
- errorString : string
- queryString : string
Methods
- void exec()
Detailed Description
Note: When you destroy your object this also destroys the the instance of QmlSqlQueryModel, thus everytime it gets recreated. Some people may wish to put this object in a qml file that never gets destoryed till the application is destroyed.
QmlSqlQueryModel is a high-level interface for executing SQL statements and traversing the result set. It is built on top of the lower-level QSqlQuery and can be used to provide data to views such as ListView. For example Say that we have a QmlSqlDatabase open with te connectionName of "master-connection"
ListView{ model: sqlModel } QmlSqlQueryModel{ id: sqlModel connectionName: "master-connection" queryString: "SELECT name, salary FROM employee" Component.onCompleted:{ exec() } }
The model is read-only by default. To make it writable you can use QmlSqlQuery but in the near future there will be a option to set it as writable.
The querymodel example illustrates how to use QmlSqlQueryModel to display the result of a query.
Property Documentation
Set the connectionName to connectionName. This is used on a open QmlSqlDatabase,
Returns information about the last error that occurred on the database.
See also exec().
Resets the model and sets the data provider to be the given query.
errorString can be used to retrieve verbose information if there was an error setting the query.
See also errorString.
Method Documentation
Fills or refils the model based on the queryString that one sets. If there is a error one can use errorString or its signal onErrorStringChaned to gather information about that error
See also queryString and errorString.