How to mask a singal
-
for example:i have two singals,a click singal and a PressAndHold singal,when i deal with a singal how to mask another,thanks very much !
-
Those are individual signals. So you can connect them to different slots. What would you need masking for then?
-
in gridview,on the one hand i want to click a picture then display it in full screen,on the other hand i want use onPressAndHold:{}and onReleased{} to implement drag and drop to change picture's position,drag and drop do it well but onclick:{} can not implement!
-
Somehow you have managed already part of the signal-slot mechanism. You should try to post a small example highlighting your problem.
-
I don't know if you can ignore the click() signal. You can ignore the handling of your code inside the onClicked: slot.
Inside your onPressAndHold: , set a variable to tell that you got long press. And when you get onClicked: slot, check if onPressAndHold was handled with the help of the variable you are setting.
-
how to ignore onPressAndHold :{} in onClick:{}
-
the code is :
@
import QtQuick 1.0Rectangle {
width: 800
height: 420
color: "#222222"
Component {
id: widgetdelegate
Item {
id:refer
width: grid.cellWidth; height: grid.cellHeight
Image {
id: im
source: portrait;
anchors.centerIn: parent
width: grid.cellWidth - 10; height: grid.cellHeight - 10
smooth: true
MouseArea{onClicked: { console.log("test") }//here do not carry out } //fillMode: Image.PreserveAspectFit Rectangle { id: imRect anchors.fill: parent; radius: 5 anchors.centerIn: parent border.color: "#326487"; color: "transparent"; border.width: 6; opacity: 0 } } Rectangle { id: iWasHere width: 20; height: 20; radius: 20 smooth: true anchors.centerIn: parent color: "white"; opacity: 0 } states: [ State { name: "inDrag" when: index == grid.firstIndexDrag PropertyChanges { target: iWasHere; opacity: 1 } PropertyChanges { target: imRect; opacity: 1 } PropertyChanges { target: im; parent: container } PropertyChanges { target: im; width: (grid.cellWidth - 10) / 2 } PropertyChanges { target: im; height: (grid.cellHeight - 10) / 2 } PropertyChanges { target: im; anchors.centerIn: undefined } PropertyChanges { target: im; x: coords.mouseX - im.width/2 } PropertyChanges { target: im; y: coords.mouseY - im.height/2 } } ] transitions: [ Transition { NumberAnimation { properties: "width, height, opacity"; duration: 300; easing.type: Easing.InOutQuad } } ] } } GridView { property int firstIndexDrag: -1
flow: GridView.TopToBottom
id: grid
x: 0; y: 0
//interactive: false//anchors.rightMargin: 200 // anchors.bottomMargin: 100 //anchors.leftMargin: 200 //anchors.topMargin: 100 anchors.fill: parent cellWidth: parent.width/5; cellHeight: parent.height/3; model: WidgetModel { id: widgetmodel } delegate: widgetdelegate Item { id: container anchors.fill: parent } MouseArea { id: coords anchors.fill: parent onReleased: { if (grid.firstIndexDrag != -1) widgetmodel.move(grid.firstIndexDrag,grid.indexAt(mouseX, mouseY),1) grid.firstIndexDrag = -1 grid.interactive=true } onPressAndHold: { console.log("the x and the y is") console.log(coords.mouseX) console.log(coords.mouseY) grid.firstIndexDrag=grid.indexAt(mouseX, mouseY) grid.interactive=false } } }
}
@[EDIT: code formatting, please wrap in @-tags, Volker]
-
sfjam, you need to enclose your code with '@' characters. One at the start of your code list and one after the last line.
Like this here:
@
first line of code
second line of code
@ -
DELETED Post:
- removed code
- please check if some of the moderators has done it, before you repost
- if you need to format, edit your original post or comment, it has an edit link on the right, just below your username/avater
- do not just repost everything in a new comment
thanks, Volker
-
Sorry, I am not of any help at all here. I am on Qt C++ only.
-
Hi,
The mouse parameter available in onClicked should have a wasHeld property that is set to true if there was a pressAndHold. e.g. you should be able to test this like:
@
onClicked: if (mouse.wasHeld) return;
@From memory, for QtQuick 1.1 the behavior was slightly changed so that onClicked will not fire if the mouse event in onPressAndHold is accepted (which it is by default if onPressAndHold is specified).
Regards,
Michael -
onClicked will not fire if the mouse event in onPressAndHold is accepted (which it is by default if onPressAndHold is specified),
can we change this?