QObject cloning

Posted by Olorin on Stack Overflow See other posts from Stack Overflow or by Olorin
Published on 2010-05-18T08:11:49Z Indexed on 2010/05/18 9:50 UTC
Read the original article Hit count: 465

Filed under:
|
|
|

I know that Qobjects are supposed to be identities not values eg you cannot copy them and by default the copy constructor and asignment are disabled as explained in qt documentation. But is it possible to create a new Qobject from an existing one using a clone method? Would this be a logic error ? If i say

QObject b; 
QObject a; 
b.cloneFrom(a);

or

QObject a = new QBject();
QObject b = new QBject();
b->cloneFrom(a);

and the clone method copyes stuff like members etc would this be wrong?

And if this is ok can i write my own copy constructor and asignment operator that does just that?

Note: i actually want to try this with classes that inherit qobject.

© Stack Overflow or respective owner

Related posts about c++

Related posts about qt