신호를 인수없이 .disconnect()
를 호출하는 것은 불가능 :Qt5 QML의 신호에서 모든 슬롯을 분리 할 수 있습니까? QML에서
file:mainwindow.qml:107: Error: Function.prototype.disconnect: no arguments given
그래서 어떻게 그들 각각을 지정하지 않고 모든 슬롯을 분리 할 수 있습니까? 아니면 신호 객체를 C++
에 전달하고 어떻게 든 연결을 끊을 수 있습니까? 또는 해결 방법이 있습니까?
도달하고자하는 목표는 신호에 다른 슬롯을 연결하여 개체의 동작을 변경하는 것입니다. 예를 들어 :
Item {
property var fire
// Any qml object. In this example it is ActionExecutor which emits actionRequest
ActionExecutor {
//signal actionRequest(int actionType)
onActionRequest: fire(actionType)
}
Action {
shortcut: "Ctrl+S"
text: "One action"
onTriggered: {
parent.fire = function(actionType) {
console.log('one slot')
}
}
}
Action {
shortcut: "Ctrl+X"
text: "Another action"
onTriggered: {
parent.fire = function(actionType) {
console.log('Another slot')
}
}
}
}
그래서 그 객체를 재 할당 할 수 있습니다 JS : 내부에서 JSObject를 호출하는 하나 개의 신호에 한 번만 연결 :
object.disconnect() // disconnect all slots
object.connect(one_super_slot)
object.disconnect() // disconnect all slots
object.connect(another_super_slot)