QtBase  v6.3.1
Classes | Functions | Variables
sqldatabase_snippet.cpp File Reference

Go to the source code of this file.

Classes

class  MyModel
 [Quoting ModelView Tutorial] More...
 
class  XyzResult
 [47] More...
 
class  XyzDriver
 [47] More...
 

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] More...
 
view show ()
 [18] //! [19] More...
 
view setEditTriggers (QAbstractItemView::NoEditTriggers)
 [16] //! [19] //! [20] More...
 
 Q_UNUSED (salary)
 [21] More...
 
 for (int row=0;row< model.rowCount();++row)
 [0] More...
 
void QSqlTableModel_snippets ()
 [23] More...
 
void sql_intro_snippets ()
 
int main (int argc, char **argv)
 [48] More...
 

Variables

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

Function Documentation

◆ for()

for ( )

[0]

[10]

[1]

[11]

[0]

[4]

Definition at line 81 of file sqldatabase_snippet.cpp.

Here is the call graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

[48]

[1]

[2]

Create an application and a main widget. Open the main widget for user input, and exit with an appropriate return value when it is closed.

[6]

[0]

[1]

[1] //! [2]

[2]

[3]

[3]

[4]

[4] //! [5]

[5] //! [6]

[0] [1]

[1] [2]

[0]

[1]

[1] //! [2]

[2]

[3]

[3]

[4]

[4] //! [5]

[5] //! [6]

[0]

[0]

[1]

[1]

[2]

[2]

[3]

[3]

[4]

[4]

[0]

[0]

[1]

[1]

[0]

[0]

[0]

[0]

Definition at line 375 of file sqldatabase_snippet.cpp.

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
QVariant data(const QModelIndex &item, int role=Qt::DisplayRole) const override
int toInt(bool *ok=nullptr) const
Definition: qvariant.cpp:1833
QSqlQueryModel * model
[16]
int salary

[21]

[22]

◆ QSqlTableModel_snippets()

void QSqlTableModel_snippets ( )

[23]

[24]

[24]

[25]

[25]

Definition at line 107 of file sqldatabase_snippet.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setEditTriggers()

view setEditTriggers ( QAbstractItemView::NoEditTriggers  )

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

◆ setHeaderData() [1/2]

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

◆ setHeaderData() [2/2]

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

◆ setModel()

view setModel ( model  )

[17] //! [18]

◆ setQuery()

model setQuery ( "SELECT  name,
salary FROM employee  
)

◆ show()

view show ( )

[18] //! [19]

Here is the caller graph for this function:

◆ sql_intro_snippets()

void sql_intro_snippets ( )

[26]

[26]

[27]

[27]

[28]

[28] //! [29]

[29] //! [30]

[30]

[31]

[31]

[32]

[32]

[33]

[33]

[34]

[34]

[35]

[35]

[36]

[36]

[37]

[37]

[38]

[38]

[39]

[39]

[40]

[40]

[41]

[41]

[42]

[42]

[43]

[43]

[44]

[44]

[45]

[45] //! [46]

[46]

Definition at line 133 of file sqldatabase_snippet.cpp.

Here is the call graph for this function:

Variable Documentation

◆ model

[16]

[20]

[21]

Definition at line 52 of file sqldatabase_snippet.cpp.

◆ salary

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

Definition at line 70 of file sqldatabase_snippet.cpp.

◆ view

QTableView* view = new QTableView

[17]

Definition at line 57 of file sqldatabase_snippet.cpp.