aboutsummaryrefslogtreecommitdiffstats
path: root/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp
blob: e91b7ed1bde1b6c2b7e17e07213cd27020b23a43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//! [0]
QLineEdit  myEditor(this);
Q3SqlForm   myForm(this);
Q3SqlCursor myCursor("mytable");

// Execute a query to make the cursor valid
myCursor.select();
// Move the cursor to a valid record (the first record)
myCursor.next();
// Set the form's record pointer to the cursor's edit buffer (which
// contains the current record's values)
myForm.setRecord(myCursor.primeUpdate());

// Insert a field into the form that uses myEditor to edit the
// field 'somefield' in 'mytable'
myForm.insert(&myEditor, "somefield");

// Update myEditor with the value from the mapped database field
myForm.readFields();
...
// Let the user edit the form
...
// Update the database
myForm.writeFields();  // Update the cursor's edit buffer from the form
myCursor.update();        // Update the database from the cursor's buffer
//! [0]