I have defined a couple of context variables from C++, something like this:
@class MyClass : public QObject
Q_PROPERTY(QString name ...)
MyClass myVar1, myVar2;
QQmlContext *ctxt = m_pMainView->rootContext();
myVar1 = myVar2;
myVar1 = 3.0;
myVar1 = "Fred";
Are there any macros I can insert into MyClass, or anything clever I can do that will make the operator= actually do something?
Hmm this can't work because your registred variables are a class and you want to set the value of a property of this class. So i think this is the right way
myvar1.name = "name"
Yes, it would work to specify the values one at a time, the problem is that I would like to copy all of the values from myVar2 to myVar1, which means I need to write
@myVar1.name = myVar2.name;
myVar1.target = myVar2.target;
myVar1.size = myVar2.size;
etc. etc. etc.
which is not only annoying, but is error-prone and violates several object-oriented design principles.
And yes, Qml and JavaCcript are interpreted and C++ is compiled, the problem is that the interpreter doesn't give me warnings or errors ever - including when the program is running and the Qml is interpreted and executed.
@myVar1 = myVar2;
it should make myVar1 refer to the same object as myVar2 but that isn't happening, and no errors or warnings are being generated.