I have a problem with QML1 and signal disconnections.
I'm using Qt 5.1. The problem does not appear with QML2.
I searched online but it does not seem a known problem therefore I think this may be my fault anyway.
My application is structured with a numeric edit panel with a numeric keypad (called NumericInputpanel).
When instances of my particular QtQuick widget (called NumericInputFrameLabel) are clicked, the NumericInputpanel is shown in the bottom part of the screen.
When keypad buttons (of NumericInputpanel) are clicked I want change value (that is the text) of my NumericInputFrameLabel.
To do this I tried to use signals "connect/disconnect" on QML.
When my NumericInputFrameLabel is clicked is called the callback "connectItem()"
var numericIP = Utils.getNumericInputPanel(nifl); // function get the instantiated numericInputPanel on top level!
if (Utils.assert(numericIP,"")) return; // It works.. don't care about it..
[...]
// connect
numericIP.update.connect(updateText) // callback to update NumericInputFrameLabel text
// init numeric input
numericIP.value = frameText.text // initialization of numeric ip getting current value..
[...]
// show numeric input
stateMachine.showNumericInput();
var numericIP = Utils.getNumericInputPanel(nifl); // function get the instantiated numericInputPanel on top level!
if (Utils.assert(numericIP,"")) return; // It works.. don't care about it..
[...]
// connect
numericIP.update.connect(updateText) // callback to update NumericInputFrameLabel text
// init numeric input
numericIP.value = frameText.text // initialization of numeric ip getting current value..
[...]
// show numeric input
stateMachine.showNumericInput();
To copy to clipboard, switch view to plain text mode
This works without any problem.
The problem happens when I close the NumericInputPanel.
When it is closed is called a callback "disconnectItem"():
var numericIP = Utils.getNumericInputPanel(nifl); // as connect callback
if (Utils.assert(numericIP,"Cannot disconnect (1)")) return;
var mainScreen = Utils.getMainScreen(nifl);
if (Utils.assert(mainScreen,"Cannot disconnect (2)")) return;
[...]
// disconnect
numericIP.update.disconnect(updateText) // disconnect the signal NOT WORKS WITH QML1!!!!!!!
[...]
// update frame text
nifl.defaultValue = frameText.text
// hide numeric input
stateMachine.hideNumericInput();
// slide down main screen
mainScreen.y = 0;
var numericIP = Utils.getNumericInputPanel(nifl); // as connect callback
if (Utils.assert(numericIP,"Cannot disconnect (1)")) return;
var mainScreen = Utils.getMainScreen(nifl);
if (Utils.assert(mainScreen,"Cannot disconnect (2)")) return;
[...]
// disconnect
numericIP.update.disconnect(updateText) // disconnect the signal NOT WORKS WITH QML1!!!!!!!
[...]
// update frame text
nifl.defaultValue = frameText.text
// hide numeric input
stateMachine.hideNumericInput();
// slide down main screen
mainScreen.y = 0;
To copy to clipboard, switch view to plain text mode
disconnectItem is called correctly but does not disconnect te signal "numericIP.update" from callback "updateText".
As wrote all works with QML2. Is there something wrong?
thanks in advance,
Nicola
update: using Qt 4.8.4 the disconnect seem works!
update2: Ok.. new update.
In old code (that work with Qt5.1 + QML2) I connect some signal with other signals.
After replacing all these "binds" with connection signal -> callback functions, all works also with Qt5.1 and QML1.
Therefore the problem seem to be related to connections signal -> signal with Qt 5.1 and QML1.
The strange thing is that with Qt4.8.4 works also with signal -> signal connections/disconnections
Bookmarks