aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick')
-rw-r--r--src/quick/doc/images/flickable-contentXY-bottom-left.pngbin0 -> 2780 bytes
-rw-r--r--src/quick/doc/images/flickable-contentXY-bottom-left.svgzbin0 -> 1575 bytes
-rw-r--r--src/quick/doc/images/flickable-contentXY-bottom-right.pngbin0 -> 2386 bytes
-rw-r--r--src/quick/doc/images/flickable-contentXY-bottom-right.svgzbin0 -> 1580 bytes
-rw-r--r--src/quick/doc/images/flickable-contentXY-resting.pngbin0 -> 430 bytes
-rw-r--r--src/quick/doc/images/flickable-contentXY-resting.svgzbin0 -> 1083 bytes
-rw-r--r--src/quick/doc/images/flickable-contentXY-top-left.pngbin0 -> 3025 bytes
-rw-r--r--src/quick/doc/images/flickable-contentXY-top-left.svgzbin0 -> 1550 bytes
-rw-r--r--src/quick/doc/images/flickable-contentXY-top-right.pngbin0 -> 2866 bytes
-rw-r--r--src/quick/doc/images/flickable-contentXY-top-right.svgzbin0 -> 1594 bytes
-rw-r--r--src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc54
-rw-r--r--src/quick/doc/src/includes/item.qdocinc6
-rw-r--r--src/quick/doc/src/qtquick-cpp.qdoc2
-rw-r--r--src/quick/items/qquickflickable.cpp27
-rw-r--r--src/quick/items/qquickitem.cpp31
-rw-r--r--src/quick/items/qquickloader.cpp8
-rw-r--r--src/quick/items/qquickrendercontrol.cpp3
-rw-r--r--src/quick/util/qquicktransition.cpp1
18 files changed, 115 insertions, 17 deletions
diff --git a/src/quick/doc/images/flickable-contentXY-bottom-left.png b/src/quick/doc/images/flickable-contentXY-bottom-left.png
new file mode 100644
index 0000000000..47d3be4625
--- /dev/null
+++ b/src/quick/doc/images/flickable-contentXY-bottom-left.png
Binary files differ
diff --git a/src/quick/doc/images/flickable-contentXY-bottom-left.svgz b/src/quick/doc/images/flickable-contentXY-bottom-left.svgz
new file mode 100644
index 0000000000..db86262d74
--- /dev/null
+++ b/src/quick/doc/images/flickable-contentXY-bottom-left.svgz
Binary files differ
diff --git a/src/quick/doc/images/flickable-contentXY-bottom-right.png b/src/quick/doc/images/flickable-contentXY-bottom-right.png
new file mode 100644
index 0000000000..eb9eff24c5
--- /dev/null
+++ b/src/quick/doc/images/flickable-contentXY-bottom-right.png
Binary files differ
diff --git a/src/quick/doc/images/flickable-contentXY-bottom-right.svgz b/src/quick/doc/images/flickable-contentXY-bottom-right.svgz
new file mode 100644
index 0000000000..088c1bdf1e
--- /dev/null
+++ b/src/quick/doc/images/flickable-contentXY-bottom-right.svgz
Binary files differ
diff --git a/src/quick/doc/images/flickable-contentXY-resting.png b/src/quick/doc/images/flickable-contentXY-resting.png
new file mode 100644
index 0000000000..11bde53da5
--- /dev/null
+++ b/src/quick/doc/images/flickable-contentXY-resting.png
Binary files differ
diff --git a/src/quick/doc/images/flickable-contentXY-resting.svgz b/src/quick/doc/images/flickable-contentXY-resting.svgz
new file mode 100644
index 0000000000..c8ac118048
--- /dev/null
+++ b/src/quick/doc/images/flickable-contentXY-resting.svgz
Binary files differ
diff --git a/src/quick/doc/images/flickable-contentXY-top-left.png b/src/quick/doc/images/flickable-contentXY-top-left.png
new file mode 100644
index 0000000000..de3d11d283
--- /dev/null
+++ b/src/quick/doc/images/flickable-contentXY-top-left.png
Binary files differ
diff --git a/src/quick/doc/images/flickable-contentXY-top-left.svgz b/src/quick/doc/images/flickable-contentXY-top-left.svgz
new file mode 100644
index 0000000000..bcb6476cd2
--- /dev/null
+++ b/src/quick/doc/images/flickable-contentXY-top-left.svgz
Binary files differ
diff --git a/src/quick/doc/images/flickable-contentXY-top-right.png b/src/quick/doc/images/flickable-contentXY-top-right.png
new file mode 100644
index 0000000000..7f4a16bde1
--- /dev/null
+++ b/src/quick/doc/images/flickable-contentXY-top-right.png
Binary files differ
diff --git a/src/quick/doc/images/flickable-contentXY-top-right.svgz b/src/quick/doc/images/flickable-contentXY-top-right.svgz
new file mode 100644
index 0000000000..32b721cb6b
--- /dev/null
+++ b/src/quick/doc/images/flickable-contentXY-top-right.svgz
Binary files differ
diff --git a/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc b/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
index f27f87e743..c8bdfa28cd 100644
--- a/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
+++ b/src/quick/doc/src/guidelines/qtquick-bestpractices.qdoc
@@ -59,20 +59,19 @@ custom control.
\li \l{Qt Quick}
\endlist
+\omit
\section1 Keep it Short and Simple or "KiSS"
QML being a declarative language, a lot of the details are worked out by the underlying
engine. So it is important for any QML application, especially one with a
larger codebase, to have its code organized in smaller and simpler \c .qml files.
-\omit
-need a few snippet or example applications that showcase this.
+TODO: need a few snippet or example applications that showcase this.
\endomit
-\section2 Related Information
-\list
- \li \l{QML Coding Conventions}
-\endlist
+\section1 Coding Conventions
+
+See \l{QML Coding Conventions}.
\section1 Bundle Application Resources
@@ -338,8 +337,9 @@ must be considered while using them:
\section2 Dos
\list
- \li Use anchors or the item's width and height properties to specify the size
- of the layout against its parent.
+ \li Use \l {Item::}{anchors} or the \l {Item::}{width} and \l {Item::}{height}
+ properties to specify the size of the layout against its non-layout parent
+ item.
\li Use the \l Layout attached property to set the size and alignment
attributes of the layout's immediate children.
\endlist
@@ -347,12 +347,10 @@ must be considered while using them:
\section2 Don'ts
\list
- \li Do not rely on anchors to specify the preferred size of an item in a layout.
- Instead, use \c Layout.preferredWidth and \c Layout.preferredHeight.
\li Do not define preferred sizes for items that provide implicitWidth and
implicitHeight, unless their implicit sizes are not satisfactory.
- \li Do not mix anchors and layouts in ways that cause conflicts. For example,
- do not apply anchor constraints to a layout's immediate children.
+ \li Do not use anchors on an item that is an immediate child of a layout.
+ Instead, use \c Layout.preferredWidth and \c Layout.preferredHeight:
\snippet qml/windowconstraints.qml rowlayout
\endlist
@@ -369,6 +367,36 @@ properties are enough.
\li \l{Qt Quick Layouts Overview}
\endlist
+\section1 Type Safety
+
+When declaring properties in QML, it's easy and convenient to use the "var" type:
+
+\code
+property var name
+property var size
+property var optionsMenu
+\endcode
+
+However, this approach has several disadvantages:
+\list
+ \li If a value with the wrong type is assigned, the error reported will point
+ to the location of the property declaration, as opposed to the location
+ where the property was assigned to. This slows down the development
+ process by making it more difficult to track down errors.
+ \li Static anaylsis to catch errors like the ones mentioned above is not
+ possible.
+ \li The actual underlying type of the property is not always immediately clear
+ to the reader.
+\endlist
+
+Instead, always use the actual type where possible:
+
+\code
+property string name
+property int size
+property MyMenu optionsMenu
+\endcode
+
\section1 Performance
For information on performance in QML and Qt Quick,
@@ -420,7 +448,7 @@ on the display resolution on offer.
\section2 Related Information
\list
- \li \l{Qt Quick Controls 2 - Gallery Example}{Gallery example}
+ \li \l{Qt Quick Controls 2 - Gallery}{Gallery example}
\li \l{Qt Quick Controls 2 - Text Editor}{Text Editor example}
\li \l{Font Awesome}
\li \l{Scalability}
diff --git a/src/quick/doc/src/includes/item.qdocinc b/src/quick/doc/src/includes/item.qdocinc
new file mode 100644
index 0000000000..12472cb928
--- /dev/null
+++ b/src/quick/doc/src/includes/item.qdocinc
@@ -0,0 +1,6 @@
+//! [mapping]
+
+The following properties of the item are used in the mapping:
+\l x, \l y, \l scale, \l rotation, \l transformOrigin, and \l [QML]{Item::}{transform}.
+
+//! [mapping]
diff --git a/src/quick/doc/src/qtquick-cpp.qdoc b/src/quick/doc/src/qtquick-cpp.qdoc
index ca6fe3d0c0..8a1ab915f2 100644
--- a/src/quick/doc/src/qtquick-cpp.qdoc
+++ b/src/quick/doc/src/qtquick-cpp.qdoc
@@ -38,10 +38,12 @@
\snippet code/doc_src_qtquick.cpp 0
+ \if !defined(qtforpython)
To link against the module, add this line to your \l qmake \c
.pro file:
\snippet code/doc_src_qtquick.pro 0
+ \endif
For more information on the Qt Quick module, see the
\l{Qt Quick} module documentation.
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index 5a3db5e1eb..b47d055ca4 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -633,6 +633,31 @@ void QQuickFlickablePrivate::updateBeginningEnd()
\c contentItem that are relevant. For example, the bound of Items added
to the Flickable will be available by \c contentItem.childrenRect
+ \section1 Examples of contentX and contentY
+
+ The following images demonstrate a flickable being flicked in various
+ directions and the resulting \l contentX and \l contentY values.
+ The blue square represents the flickable's content, and the black
+ border represents the bounds of the flickable.
+
+ \table
+ \row
+ \li \image flickable-contentXY-resting.png
+ \li The \c contentX and \c contentY are both \c 0.
+ \row
+ \li \image flickable-contentXY-top-left.png
+ \li The \c contentX and the \c contentY are both \c 50.
+ \row
+ \li \image flickable-contentXY-top-right.png
+ \li The \c contentX is \c -50 and the \c contentY is \c 50.
+ \row
+ \li \image flickable-contentXY-bottom-right.png
+ \li The \c contentX and the \c contentY are both \c -50.
+ \row
+ \li \image flickable-contentXY-bottom-left.png
+ \li The \c contentX is \c 50 and the \c contentY is \c -50.
+ \endtable
+
\section1 Limitations
\note Due to an implementation detail, items placed inside a Flickable
@@ -738,7 +763,7 @@ QQuickFlickable::~QQuickFlickable()
for the position; another way is to use the normalized values in
\l {QtQuick::Flickable::visibleArea}{visibleArea}.
- \sa originX, originY
+ \sa {Examples of contentX and contentY}, originX, originY
*/
qreal QQuickFlickable::contentX() const
{
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index b09dbdad84..c1e625ef95 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -2356,6 +2356,9 @@ void QQuickItemPrivate::updateSubFocusItem(QQuickItem *scope, bool focus)
\fn QQuickItem::QQuickItem(QQuickItem *parent)
Constructs a QQuickItem with the given \a parent.
+
+ The \c parent will be used as both the \l {setParentItem()}{visual parent}
+ and the \l QObject parent.
*/
QQuickItem::QQuickItem(QQuickItem* parent)
: QObject(*(new QQuickItemPrivate), parent)
@@ -4407,6 +4410,8 @@ void QQuickItem::polish()
item's coordinate system, to this item's coordinate system, and returns a \l point or \l rect
matching the mapped coordinate.
+ \input item.qdocinc mapping
+
If \a item is a \c null value, this maps the point or rect from the coordinate system of
the root QML view.
*/
@@ -4495,6 +4500,8 @@ QTransform QQuickItem::itemTransform(QQuickItem *other, bool *ok) const
item's coordinate system, to \a item's coordinate system, and returns a \l point or \l rect
matching the mapped coordinate.
+ \input item.qdocinc mapping
+
If \a item is a \c null value, this maps the point or rect to the coordinate system of the
root QML view.
*/
@@ -4564,6 +4571,8 @@ void QQuickItem::mapToItem(QQmlV4Function *args) const
Maps the point (\a x, \a y), which is in the global coordinate system, to the
item's coordinate system, and returns a \l point matching the mapped coordinate.
+
+ \input item.qdocinc mapping
*/
/*!
\internal
@@ -4599,6 +4608,8 @@ void QQuickItem::mapFromGlobal(QQmlV4Function *args) const
Maps the point (\a x, \a y), which is in this item's coordinate system, to the
global coordinate system, and returns a \l point matching the mapped coordinate.
+
+ \input item.qdocinc mapping
*/
/*!
\internal
@@ -7701,6 +7712,8 @@ void QQuickItem::setContainmentMask(QObject *mask)
point within \a item's coordinate system, and returns the mapped
coordinate.
+ \input item.qdocinc mapping
+
If \a item is 0, this maps \a point to the coordinate system of the
scene.
@@ -7719,6 +7732,8 @@ QPointF QQuickItem::mapToItem(const QQuickItem *item, const QPointF &point) cons
point within the scene's coordinate system, and returns the mapped
coordinate.
+ \input item.qdocinc mapping
+
\sa {Concepts - Visual Coordinates in Qt Quick}
*/
QPointF QQuickItem::mapToScene(const QPointF &point) const
@@ -7732,6 +7747,8 @@ QPointF QQuickItem::mapToScene(const QPointF &point) const
point within global screen coordinate system, and returns the mapped
coordinate.
+ \input item.qdocinc mapping
+
For example, this may be helpful to add a popup to a Qt Quick component.
\note Window positioning is done by the window manager and this value is
@@ -7753,6 +7770,8 @@ QPointF QQuickItem::mapToGlobal(const QPointF &point) const
rectangular area within \a item's coordinate system, and returns the mapped
rectangle value.
+ \input item.qdocinc mapping
+
If \a item is 0, this maps \a rect to the coordinate system of the
scene.
@@ -7772,6 +7791,8 @@ QRectF QQuickItem::mapRectToItem(const QQuickItem *item, const QRectF &rect) con
rectangular area within the scene's coordinate system, and returns the mapped
rectangle value.
+ \input item.qdocinc mapping
+
\sa {Concepts - Visual Coordinates in Qt Quick}
*/
QRectF QQuickItem::mapRectToScene(const QRectF &rect) const
@@ -7785,6 +7806,8 @@ QRectF QQuickItem::mapRectToScene(const QRectF &rect) const
point within this item's coordinate system, and returns the mapped
coordinate.
+ \input item.qdocinc mapping
+
If \a item is 0, this maps \a point from the coordinate system of the
scene.
@@ -7801,6 +7824,8 @@ QPointF QQuickItem::mapFromItem(const QQuickItem *item, const QPointF &point) co
point within this item's coordinate system, and returns the mapped
coordinate.
+ \input item.qdocinc mapping
+
\sa {Concepts - Visual Coordinates in Qt Quick}
*/
QPointF QQuickItem::mapFromScene(const QPointF &point) const
@@ -7814,6 +7839,8 @@ QPointF QQuickItem::mapFromScene(const QPointF &point) const
equivalent point within this item's coordinate system, and returns the
mapped coordinate.
+ \input item.qdocinc mapping
+
For example, this may be helpful to add a popup to a Qt Quick component.
\note Window positioning is done by the window manager and this value is
@@ -7835,6 +7862,8 @@ QPointF QQuickItem::mapFromGlobal(const QPointF &point) const
rectangular area within this item's coordinate system, and returns the mapped
rectangle value.
+ \input item.qdocinc mapping
+
If \a item is 0, this maps \a rect from the coordinate system of the
scene.
@@ -7853,6 +7882,8 @@ QRectF QQuickItem::mapRectFromItem(const QQuickItem *item, const QRectF &rect) c
rectangular area within this item's coordinate system, and returns the mapped
rectangle value.
+ \input item.qdocinc mapping
+
\sa {Concepts - Visual Coordinates in Qt Quick}
*/
QRectF QQuickItem::mapRectFromScene(const QRectF &rect) const
diff --git a/src/quick/items/qquickloader.cpp b/src/quick/items/qquickloader.cpp
index 0de9d6c49a..f32f25a42f 100644
--- a/src/quick/items/qquickloader.cpp
+++ b/src/quick/items/qquickloader.cpp
@@ -112,6 +112,8 @@ void QQuickLoaderPrivate::clear()
q, SIGNAL(progressChanged()));
component->deleteLater();
component.setObject(nullptr, q);
+ } else if (component) {
+ component.setObject(nullptr, q);
}
source = QUrl();
@@ -437,7 +439,8 @@ void QQuickLoader::loadFromSource()
if (isComponentComplete()) {
QQmlComponent::CompilationMode mode = d->asynchronous ? QQmlComponent::Asynchronous : QQmlComponent::PreferSynchronous;
- d->component.setObject(new QQmlComponent(qmlEngine(this), d->source, mode, this), this);
+ if (!d->component)
+ d->component.setObject(new QQmlComponent(qmlEngine(this), d->source, mode, this), this);
d->load();
}
}
@@ -823,7 +826,8 @@ void QQuickLoader::componentComplete()
if (active()) {
if (d->loadingFromSource) {
QQmlComponent::CompilationMode mode = d->asynchronous ? QQmlComponent::Asynchronous : QQmlComponent::PreferSynchronous;
- d->component.setObject(new QQmlComponent(qmlEngine(this), d->source, mode, this), this);
+ if (!d->component)
+ d->component.setObject(new QQmlComponent(qmlEngine(this), d->source, mode, this), this);
}
d->load();
}
diff --git a/src/quick/items/qquickrendercontrol.cpp b/src/quick/items/qquickrendercontrol.cpp
index b06b0821d2..86a64cdeeb 100644
--- a/src/quick/items/qquickrendercontrol.cpp
+++ b/src/quick/items/qquickrendercontrol.cpp
@@ -385,7 +385,8 @@ QImage QQuickRenderControl::grab()
cd->syncSceneGraph();
d->rc->endSync();
render();
- grabContent = qt_gl_read_framebuffer(d->window->size() * d->window->effectiveDevicePixelRatio(), false, false);
+ const bool alpha = d->window->format().alphaBufferSize() > 0 && d->window->color().alpha() < 255;
+ grabContent = qt_gl_read_framebuffer(d->window->size() * d->window->effectiveDevicePixelRatio(), alpha, alpha);
if (QQuickRenderControl::renderWindowFor(d->window)) {
grabContent.setDevicePixelRatio(d->window->effectiveDevicePixelRatio());
}
diff --git a/src/quick/util/qquicktransition.cpp b/src/quick/util/qquicktransition.cpp
index c8699426f2..ad451c8f8b 100644
--- a/src/quick/util/qquicktransition.cpp
+++ b/src/quick/util/qquicktransition.cpp
@@ -211,6 +211,7 @@ QQuickTransitionInstance::QQuickTransitionInstance(QQuickTransition *transition,
QQuickTransitionInstance::~QQuickTransitionInstance()
{
+ stop();
removeStateChangeListener();
delete m_anim;
}