58 model->setTable(
"employee");
72int main(
int argc,
char **argv)
QVariant data(const QModelIndex &item, int role) const override
Returns the data stored under the given role for the item referred to by the index.
void setEditTriggers(EditTriggers triggers)
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Returns the index of the data in row and column with parent.
The QSqlQueryModel class provides a read-only data model for SQL result sets.
QVariant data(const QModelIndex &item, int role=Qt::DisplayRole) const override
Returns the value for the specified item and role.
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void setQuery(QSqlQuery &&query)
Resets the model and sets the data provider to be the given query.
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole) override
Sets the caption for a horizontal header for the specified role to value.
int columnCount(const QModelIndex &parent=QModelIndex()) const override
\reimp
QSqlRecord record(int row) const
Returns the record containing information about the fields of the current query.
QVariant value(int i) const
Returns the value of the field located at position index in the record.
The QSqlTableModel class provides an editable data model for a single database table.
The QTableView class provides a default model/view implementation of a table view.
void setModel(QAbstractItemModel *model) override
\reimp
void hideColumn(int column)
Hide the given column.
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
GLenum GLenum GLsizei void * row
void QSqlField_snippets()
void QSqlDatabase_snippets()
void QSqlQueryModel_snippets()
void QSqlQuery_snippets()
QSqlQueryModel * model
[16]
void QSqlTableModel_snippets()
QApplication app(argc, argv)
[0]