Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

How to discern between user and programming generated events in QtQuick controls?

$
0
0
I’m doing some tests with QtQuick controls to find out how to use it in a bigger project. I’m controlling a webcam and i want to connect a QML spinbox to a C++ module so i can change the exposure time of the webcam. I successfully connected the spinbox so i can change the exposure and i can check on a QML label the state of the C++ property. Now i want to update the state of the spinbox if the exposure property changes in the C++ module. If i bind the two propertyes together the update happens only one way so i tried to use “onValueChanged”. The problem is that the event “valueChanged” is emitted not only when the user interacts but also if the software changes the value. If i connect both events like: //C++ module connected to the camera CppCore {     id: cppCore     onValueChanged: spinBoxExposure.value = value; } //QML control connected to the user SpinBox {     id: spinboxExposure     onValueChanged: cppCore.value = value; } It all loops and go crazy :-) . In QtWidget i remember i avoided the problem using signals emitted only by user interaction or disconnecting the events when needed. How can i do the same in QML? I think this problem can surface in a other environments, how are you dealing with it?

Viewing all articles
Browse latest Browse all 4972

Trending Articles