3

I want to make my first BB10 app. My Questions is, should all objects extend from QObject, also custom classes that only used by a controller and not inside the QML file?

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
DevCoder
  • 111
  • 1
  • 3
  • 7

1 Answers1

1

The QObject class constructor takes a pointer to a parent QObject. When that parent QObject has its destructor called, its children will be destroyed as well. The fact that Qt keeps this object tree for you makes the memory management of the UI a lot easier. When the window gets closed, all the widgets in that tree automagically get cleaned up. That was a massive help for me when i first started working with Qt.

As a general rule of thumb, I inherit from QObject (or a derivation of QObject) for any UI component, or a component that will be used directly from the UI within QML.

Adam Linford
  • 154
  • 1