I'm writing a Qt 6.2.0 application running in Ubuntu 20.04.
My goal is to add a property to the existing class QtOpcUaNode
.
So I wrote:
class MyOpcUaNode : public QOpcUaNode
{
Q_OBJECT
public:
explicit MyOpcUaNode(QOpcUaNode *parent = nullptr) : QOpcUaNode(parent) { }
bool updated;
};
But here the first error:
error: no matching function for call to ‘QOpcUaNode::QOpcUaNode(QOpcUaNode*&)’
In file included from ../MyProject/myproject.cpp:1:
../MyProject/myproject.h: In constructor ‘MyOpcUaNode::MyOpcUaNode(QOpcUaNode*)’:
../MyProject/myproject.h:16:73: error: no matching function for call to ‘QOpcUaNode::QOpcUaNode(QOpcUaNode*&)’
16 | explicit MyOpcUaNode(QOpcUaNode *parent = nullptr) : QOpcUaNode(parent) { }
| ^
I want to use my class in this way:
QList<MyOpcUaNode *> _listOpcNodes;
_listOpcNodes.append(MyOpcUaNode(_opcUaClient->node("ns=4;s=MEM_RUN_LINE")));
...
_listOpcNodes[x]->updated = true;
Is it correct my approach?
I tried without the copy-constructor but I was not sure how to convert a QOpcUaNode *
to MyOpcUaNode *
. Trying with:
MyOpcUaNode *node = qobject_cast<MyOpcUaNode *>(_opcUaClient->node("ns=4;s=MEM_RUN_LINE"));
lead node
to be a null
pointer (even if the _opcUaClient->node
was correct).