Hello everyone!
I know QObjects doesn't support copy constructors but how can i create a copy of a QObject.
I want to make changes to the object while still maintaining the original copy.
Thanks

Recommended Answers

All 3 Replies

Change your code so that you don't fight the design of Qt. QObjects are non-copyable by design, and that was an explicit choice, so making it happen will be inherently awkward and brittle.

How about instead of keeping a copy, which I assume is because you want to have a transaction that can be rolled back, store a stack of edits and roll them back individually like an undo queue.

Please that would rather make it too complex.
Is there no way I can copy the contents of an object to another of the same class?

Please that would rather make it too complex.

Trying to copy something that's not designed to be copied isn't any better.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.