Details
-
Suggestion
-
Resolution: Fixed
-
P3: Somewhat important
-
6.3.1
-
892e9fc3b (dev)
Description
In most cases, only a change in the "Value" attribute is of interest.
There is already a function to get the value of the "Value" attribute ("QVariant QOpcUaNode::valueAttribute() const") it would make sense to have a signal for detecting changes in the variable value.
The now existing signal attributeUpdated(QOpcUa::NodeAttribute attr, QVariant value) triggers for every kind of attribute. Therefore, you always have to check in the SLOT what kind of attribute has been changed. A direct SIGNAL/SLOT (QOpcUANode/QSpinBox) connection is not possible because you have to evaluate the attribute first.
A new SIGNAL valueUpdated(QVariant value) would simplify this.
The valueUpdated(QVariant value) signal is only triggered for the "Value" attribute.
The attached source code includes the needed changes to add the signal.
Below is a simple example, printValue(QVariant value) returns the fill level of a tank, for example.
slot:
void MyClass::printValue(QVariant value)
/* Example with current Signals */
void MyClass::printValue(QOpcUa::NodeAttribute attr, QVariant value){
if(attr == QOpcUa::NodeAttribute::Value)
}
connect(mOpcNode, &QOpcUaNode::attributeUpdated, spin, &MyClass::printValue);
/* Example with new signal valueUpdated() */
connect(mOpcNode, &QOpcUaNode::valueUpdated, this, &MyClass::printValue);
Attachments
For Gerrit Dashboard: QTBUG-105519 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
497652,4 | Add valueAttributeUpdated signal | dev | qt/qtopcua | Status: MERGED | +2 | 0 |