View Full Version : QObject as base class
Caolan O'Domhnaill
17th October 2015, 01:21
Hello all,
is it a good idea to create all data objects derived from QObject? Microsoft's MFC Class CObject is built this way but I wanted to see if there is a reason NOT to do this in QT.
Cheers!
-Caolan O'Domhnaill
anda_skoa
17th October 2015, 10:52
If you mean value classes, then no.
You derive from QObject when you need things like properties, signals, slots, components that need to be treated in an abstracted way or communicate with another.
Or maybe more generically: in C++ you derive from a class if you need to do that, if your new class needs to be treatable as the base class.
Cheers,
_
Caolan O'Domhnaill
19th October 2015, 18:53
If you mean value classes, then no.
You derive from QObject when you need things like properties, signals, slots, components that need to be treated in an abstracted way or communicate with another.
Or maybe more generically: in C++ you derive from a class if you need to do that, if your new class needs to be treatable as the base class.
Cheers,
_
Aye that's what I was thinking. In MFC, the CObject class allows for serialization of your data which is why you would do it there.
Thank you!
-Caolan
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.