How to block signal in QML
-
wrote on 4 Dec 2020, 21:52 last edited by
Hi. How can I block/unblock specific signal in QML? For example "onContentYChanged".
-
wrote on 5 Dec 2020, 19:09 last edited by
@PawlosCK
It's a bit unclear to me what you want to do. If you are programatically changing contentY and you don't want a "feedback"-like reaction of your code you could define aproperty bool busy: false
which you set to true while doing your thing. The method "onContentYChanged" can then be made conditional:
onContentYChanged: { if (!busy) { } }
HTH
KR
Sebastian -
wrote on 5 Dec 2020, 22:09 last edited by
Hi. I did it and it didn't work. I mean, slot should not be executed, but I saw logs from this slot.
I wanted to block signal at startup (and later in some cases), because function setValues adds new items at startup and this signal was invoked.
I tried to disconnect signal from object using something like this (it's not from my code), but it didn't work too.mouse.clicked.disconnect(say); mouse.clicked.connect( function(){ console.log("22222") });
Next, I tried to use "Connections"
Connections { id: connection_signal_move_items target: listviewID function onCurrentItemChanged() { listviewID.moveItemsTouchAndMouse() } enabled: false } connection_signal_move_items.enabled = false connection_signal_move_items.enabled = true
and it didn't work too, so I didn't know where is problem. I thought, that I did something wrong and I started this thread.
Currently, I started use other signal and currently looks well. I have to test it more.
1/3