aboutsummaryrefslogtreecommitdiffstats
path: root/doc/codesnippets/doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'doc/codesnippets/doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp')
-rw-r--r--doc/codesnippets/doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/doc/codesnippets/doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp b/doc/codesnippets/doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp
new file mode 100644
index 000000000..72e86ba59
--- /dev/null
+++ b/doc/codesnippets/doc/src/snippets/code/tools_shared_qtgradienteditor_qtgradientdialog.cpp
@@ -0,0 +1,44 @@
+//! [0]
+ bool ok;
+ QGradient gradient = QtGradientDialog::getGradient(&ok, QRadialGradient(), this);
+ if (ok) {
+ // the user clicked OK and gradient is set to the gradient the user selected
+ } else {
+ // the user canceled the dialog; gradient is set to the initial
+ // value, in this case radial gradient
+ }
+//! [0]
+
+
+//! [1]
+ bool detailsVisible;
+ QColor::Spec spec;
+ QGradient gradient;
+
+ QtGradientDialog dlg(this);
+ dlg.setDetailsVisible(detailsVisible);
+ dlg.setSpec(spec);
+ dlg.setGradient(gradient);
+ if (dlg.exec() != QDialog::Accepted)
+ return;
+
+ gradient = dlg.gradient();
+ // detailsVisible and spec properties can be changed interactively by the user too,
+ // we store the values of these properties for the next time QtGradientDialog is executed.
+ detailsVisible = dlg.detailsVisible();
+ spec = dlg.spec();
+//! [1]
+
+
+//! [2]
+ QtGradientDialog dlg;
+ dlg.setBackgroundCheckered(true);
+//! [2]
+
+
+//! [3]
+ QtGradientDialog dlg;
+ dlg.setBackgroundCheckered(false);
+//! [3]
+
+