c++ - QT: Is it a good idea to base my domain objects on QObject? -


I'm thinking of using the QT framework in combination with C ++ to a great extent I'm wondering: Is it good to have the base of my domain classes on QObject? Or should I do this only for classes in higher classes? (Close to the user interface level). Qt documentation is not clear on this:

Taken from Qt documentation:

Meta object system is a C ++ extension that makes language properly suitable components GUI programming.

Obviously I want to make my application in a well structured manner. In the last few days I am browsing through QT documentation so that the question can be answered. I do not want to make some primary mistake which will lame my application forever; -).

I have already seen the original document for QObject and Qt object models. I have also come to know that who helped, but I did not really get help to reach the conclusion. Some who confuse me that Qt itself is not compatible with this case because all QT classes do not use Q objects as a base class.

The advantages of using QObject as a base class, as I saw

  • Signals and slots
  • Properties
  • Being able to use a protected signal
  • Internationalization
  • However, I do not need any of these functionality in most of my domain classes. Is there a best practice rule for this? Or what rule should be: If you need any of the above mentioned points, then use it?

    Hope I did not even confuse: -)

    Normally But, unless there is a "compelling necessity", you are better off keeping your domain classes "Vanilla". This will give you the most flexibility in future (such as reusing them in a non-QT environment).


    Comments