Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I derive a class from QObject?

Tags:

c++

qt

I am developing a Qt application and I am wondering if there are any benefits to create QObject classes other than adding signals and slots to them.

like image 552
Plouff Avatar asked Dec 09 '25 16:12

Plouff


1 Answers

Besides assigning signal/slot features, QObject also add a few number of reflection capabilities on C++ classes.

If you want to add a subset of a QObject you can use Q_GADGET, which add some of the reflection features and things like Q_ENUM, Q_PROPERTY, etc.

The docs has more information about it

like image 153
dfranca Avatar answered Dec 11 '25 10:12

dfranca



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!