My issue with that solution is that you're getting the information at runtime, instead of at compile time. There is increased chance of errors and there isn't really a need to inquire the meta object system in this case.
Good point Chris. The reason why I suggested otherwise is one can often store data items in QLists or QMaps that might also be needed besides a simple item counter when associated with QTreeView. But I agree, extending the associated 'model' as you suggested is much more appropriate.