aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-02-12 08:53:00 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-02-12 16:18:28 +0000
commit8784a2778063cf928b27a908f6580ed37cb4035d (patch)
tree5a0871bc6fdd795d7971bc43c3811ee467d4ff38 /src/quick/items
parent0e92e0bd6e7209ad491472b3928840ad78c5371a (diff)
Use functions as signal handlers when accessing parameters
Injected signal handlers are bad practice because they aren't declared. Task-number: QTBUG-89943 Change-Id: I3a691f68342a199bd63034637aa7ed438e3a037b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 4cc91a6a0e4f9063233a4d6554ae64855cf99c14) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/quick/items')
-rw-r--r--src/quick/items/qquickevents.cpp15
-rw-r--r--src/quick/items/qquickitem.cpp4
-rw-r--r--src/quick/items/qquickmousearea.cpp2
-rw-r--r--src/quick/items/qquicktext.cpp4
4 files changed, 13 insertions, 12 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index 8df3c1b7dd..ba9082cc2a 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -65,7 +65,7 @@ Q_LOGGING_CATEGORY(lcPointerEvents, "qt.quick.pointer.events")
\qml
Item {
focus: true
- Keys.onPressed: { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; }
+ Keys.onPressed: (event)=> { if (event.key == Qt.Key_Enter) state = 'ShowDetails'; }
}
\endqml
*/
@@ -148,7 +148,7 @@ Item {
\qml
Item {
focus: true
- Keys.onPressed: {
+ Keys.onPressed: (event)=> {
if ((event.key == Qt.Key_Enter) && (event.modifiers & Qt.ShiftModifier))
doSomething();
}
@@ -165,7 +165,7 @@ Item {
\qml
Item {
focus: true
- Keys.onPressed: {
+ Keys.onPressed: (event)=> {
if (event.matches(StandardKey.Undo))
myModel.undo();
else if (event.matches(StandardKey.Redo))
@@ -278,7 +278,7 @@ bool QQuickKeyEvent::matches(QKeySequence::StandardKey matchKey) const
For example, to react to a Shift key + Left mouse button click:
\qml
MouseArea {
- onClicked: {
+ onClicked: (mouse)=> {
if ((mouse.button == Qt.LeftButton) && (mouse.modifiers & Qt.ShiftModifier))
doSomething();
}
@@ -322,8 +322,9 @@ bool QQuickKeyEvent::matches(QKeySequence::StandardKey matchKey) const
For example, to react only to events which come from an actual mouse:
\qml
MouseArea {
- onPressed: if (mouse.source !== Qt.MouseEventNotSynthesized) {
- mouse.accepted = false
+ onPressed: (mouse)=> {
+ if (mouse.source !== Qt.MouseEventNotSynthesized)
+ mouse.accepted = false
}
onClicked: doSomething()
@@ -449,7 +450,7 @@ bool QQuickKeyEvent::matches(QKeySequence::StandardKey matchKey) const
For example, to react to a Control key pressed during the wheel event:
\qml
MouseArea {
- onWheel: {
+ onWheel: (wheel)=> {
if (wheel.modifiers & Qt.ControlModifier) {
adjustZoom(wheel.angleDelta.y / 120);
}
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 38e83e08ff..d9733309b1 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -968,7 +968,7 @@ bool QQuickKeysAttached::isConnected(const char *signalName) const
focus: true
// Ensure that we get escape key press events first.
- Keys.onShortcutOverride: event.accepted = (event.key === Qt.Key_Escape)
+ Keys.onShortcutOverride: (event)=> event.accepted = (event.key === Qt.Key_Escape)
Keys.onEscapePressed: {
console.log("escapeItem is handling escape");
@@ -1922,7 +1922,7 @@ void QQuickItemPrivate::updateSubFocusItem(QQuickItem *scope, bool focus)
Item {
focus: true
- Keys.onPressed: {
+ Keys.onPressed: (event)=> {
if (event.key == Qt.Key_Left) {
console.log("move left");
event.accepted = true;
diff --git a/src/quick/items/qquickmousearea.cpp b/src/quick/items/qquickmousearea.cpp
index 1a406dbbc2..ac7c23f7a2 100644
--- a/src/quick/items/qquickmousearea.cpp
+++ b/src/quick/items/qquickmousearea.cpp
@@ -597,7 +597,7 @@ void QQuickMouseArea::setPreventStealing(bool prevent)
MouseArea {
anchors.fill: parent
propagateComposedEvents: true
- onClicked: {
+ onClicked: (mouse)=> {
console.log("clicked blue")
mouse.accepted = false
}
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index de8c9d5297..9e56bd45e9 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -1412,7 +1412,7 @@ QQuickText::~QQuickText()
For example, this will move the first 5 lines of a Text item by 100 pixels to the right:
\code
- onLineLaidOut: {
+ onLineLaidOut: (line)=> {
if (line.number < 5) {
line.x = line.x + 100
line.width = line.width - 100
@@ -1422,7 +1422,7 @@ QQuickText::~QQuickText()
The following example will allow you to position an item at the end of the last line:
\code
- onLineLaidOut: {
+ onLineLaidOut: (line)=> {
if (line.isLast) {
lastLineMarker.x = line.x + line.implicitWidth
lastLineMarker.y = line.y + (line.height - lastLineMarker.height) / 2