aboutsummaryrefslogtreecommitdiffstats
path: root/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp')
-rw-r--r--doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp
new file mode 100644
index 000000000..e91b7ed1b
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp
@@ -0,0 +1,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]