Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
sqldatabase_snippet.cpp File Reference

(69d4ecd6ef9057cb3703178277042ff7a7411459)

Go to the source code of this file.

Classes

class  MyModel
 

Functions

model setQuery ("SELECT name, salary FROM employee")
 
model setHeaderData (0, Qt::Horizontal, tr("Name"))
 
model setHeaderData (1, Qt::Horizontal, tr("Salary"))
 
view setModel (model)
 [17] //! [18]
 
view show ()
 [18] //! [19]
 
view setEditTriggers (QAbstractItemView::NoEditTriggers)
 [16] //! [19] //! [20]
 
 Q_UNUSED (salary)
 
 for (int row=0;row< model.rowCount();++row)
 [13]
 
void QSqlTableModel_snippets ()
 
int main (int argc, char **argv)
 [48]
 

Variables

QSqlQueryModelmodel = new QSqlQueryModel
 [16]
 
QTableViewview = new QTableView
 [17]
 
int salary = model.record(4).value("salary").toInt()
 

Function Documentation

◆ for()

for ( )
new

[13]

[3]

[14]

[4]

[13]

[4]

Definition at line 30 of file sqldatabase_snippet.cpp.

◆ main()

int main ( int argc,
char ** argv )

[48]

[dynamic_tooltip]

[5]

[2]

[0]

[6]

[48]

[48]

[6]

[0]

[0]

[1]

[1]

[2]

[2]

[3]

[3]

[0]

[0]

[1]

[1]

[2]

[2]

[3]

[3]

[0]

[0]

[1]

[1]

[2]

[2]

[3]

[3]

[0]

[0]

[0]

[0]

[1]

[1]

[1]

[1]

[0]

[0]

[0]

[0]

[0]

[0]

[0]

[0]

Definition at line 72 of file sqldatabase_snippet.cpp.

References QSqlTableModel_snippets().

+ Here is the call graph for this function:

◆ Q_UNUSED()

Q_UNUSED ( salary )
Initial value:
{
int salary = model.data(model.index(4, 1)).toInt()
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Returns the index of the data in row and column with parent.
QVariant data(const QModelIndex &item, int role=Qt::DisplayRole) const override
Returns the value for the specified item and role.
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
QSqlQueryModel * model
[16]

◆ QSqlTableModel_snippets()

void QSqlTableModel_snippets ( )

[24]

[24]

[24]

[24]

Definition at line 54 of file sqldatabase_snippet.cpp.

◆ setEditTriggers()

[16] //! [19] //! [20]

◆ setHeaderData() [1/2]

model setHeaderData ( 0 ,
Qt::Horizontal ,
tr("Name")  )

◆ setHeaderData() [2/2]

model setHeaderData ( 1 ,
Qt::Horizontal ,
tr("Salary")  )

◆ setModel()

mapper setModel ( model )

[17] //! [18]

◆ setQuery()

model setQuery ( "SELECT name,
salary FROM employee"  )

◆ show()

splash show ( )

[18] //! [19]

Variable Documentation

◆ model

[16]

[0]

[20]

Definition at line 5 of file sqldatabase_snippet.cpp.

◆ salary

int salary = model.record(4).value("salary").toInt()

Definition at line 22 of file sqldatabase_snippet.cpp.

◆ view

QTableView* view = new QTableView

[17]

Definition at line 10 of file sqldatabase_snippet.cpp.