aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2018-02-15 10:42:54 +0100
committerMitch Curtis <mitch.curtis@qt.io>2018-02-16 15:02:03 +0000
commit106e7b631a8b969c851a5124d3f524ecf0b50ebf (patch)
tree1d91f1308c608c24121177567b324ac80b9bebd4 /src
parentabab7fd3268acc87997d2133a4ff9ba449f18331 (diff)
Document how to position a popup in the center of the window
This was already in Overlay's docs, but not Popup's, so this patch moves the example to a .qdocinc and includes it in both places, creating a new Popup Positioning section in the process. Change-Id: I8e8438919fd849a8466b3a28133d22bb45f7dc19 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/imports/controls/doc/src/includes/qquickoverlay-popup-parent.qdocinc20
-rw-r--r--src/quicktemplates2/qquickoverlay.cpp21
-rw-r--r--src/quicktemplates2/qquickpopup.cpp9
3 files changed, 31 insertions, 19 deletions
diff --git a/src/imports/controls/doc/src/includes/qquickoverlay-popup-parent.qdocinc b/src/imports/controls/doc/src/includes/qquickoverlay-popup-parent.qdocinc
new file mode 100644
index 00000000..7ad8a003
--- /dev/null
+++ b/src/imports/controls/doc/src/includes/qquickoverlay-popup-parent.qdocinc
@@ -0,0 +1,20 @@
+The following example uses the attached \l {Overlay::overlay}{Overlay.overlay}
+property to position a popup in the center of the window, despite the position
+of the button that opens the popup:
+
+\code
+Button {
+ onClicked: popup.open()
+
+ Popup {
+ id: popup
+
+ parent: Overlay.overlay
+
+ x: (parent.width - width) / 2
+ y: (parent.height - height) / 2
+ width: 100
+ height: 100
+ }
+}
+\endcode
diff --git a/src/quicktemplates2/qquickoverlay.cpp b/src/quicktemplates2/qquickoverlay.cpp
index 38f7949e..fe61dae2 100644
--- a/src/quicktemplates2/qquickoverlay.cpp
+++ b/src/quicktemplates2/qquickoverlay.cpp
@@ -60,26 +60,9 @@ QT_BEGIN_NAMESPACE
\l {Popup::dim}{dimmed} popup is visible.
The overlay is an ordinary Item that covers the entire window. It can be used
- as a visual parent to position a popup in scene coordinates. The following
- example uses the attached \c overlay property to position a popup to the center
- of the window, despite the position of the button that opens the popup.
+ as a visual parent to position a popup in scene coordinates.
- \code
- Button {
- onClicked: popup.open()
-
- Popup {
- id: popup
-
- parent: Overlay.overlay
-
- x: (parent.width - width) / 2
- y: (parent.height - height) / 2
- width: 100
- height: 100
- }
- }
- \endcode
+ \include qquickoverlay-popup-parent.qdocinc
\sa ApplicationWindow
*/
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index 207a886b..03328b43 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -168,6 +168,15 @@ QT_BEGIN_NAMESPACE
}
\endcode
+ \section1 Popup Positioning
+
+ Similar to items in Qt Quick, Popup's \l x and \l y coordinates are
+ relative to its parent. This means that opening a popup that is a
+ child of a \l Button, for example, will cause the popup to be positioned
+ relative to the button.
+
+ \include qquickoverlay-popup-parent.qdocinc
+
\sa {Popup Controls}, {Customizing Popup}, ApplicationWindow
*/