c++ - QList children - struct or custom classes derived from QObject? -


i'm working on qt application on symbian platform. application has sqlite database , initial data populated txt files.

i'm implementing online update data comes in json format. create generic functions in db update class takes qlist of classes/structs , updated db them. qlist populated objects either txt, or json.

i have parsing in place, considering better in terms performance:

  1. creating c++ structs , passing them (as objects hold simple data) wrapped in qlist
  2. creating custom classes derived qobject , passing them pointers in qlist , deleting qdeleteall
  3. any other way...

that depends on whether classes carrying behaviour or state.

  1. they carry behaviour.

    then, polymorphic class in order, yes. whether needs inherit qobject question. inherit qobject only if need services (introspection, signals/slots, event handling). otherwise, don't.

    as qdeleteall(): wouldn't go there. instead of naked pointers, use smart pointers, e.g. qsharedpointer. keep track of number of references payload, deleting when refcount falls zero.

    in case, don't use qlist, more efficient container such qvector.

  2. they carry state.

    then, "dumb" struct may suffice. in case, don't use qlist container, more efficient, qvector (don't forget make use of reserve() method).

in general, try avoid qlist<t> types t sizeof(t)>sizeof(void*) , non-buildin/non-qt-types, because qlist performance degraded these.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -