Re: how to pass a QList pointer

Originally Posted by
ehnuh
Hi, I would like to ask how to properly pass a QList to another function? I have researched and discovered that QLists must be passed via pointer.
wrong. QLists can be passed by value or by reference or via indirection (pointer).
pick your poison:
void func(QList<int> list) // func will use a copy of list
void func(QList<int>& list) // func will use the same instance of list
void func(QList<int> const & list) // func will use the same instance of list and will not* modify it
void func(QList<int>* list) // func will take a pointer to a QList<int> (that may be valid or not...)
PS
This is a general programming question, not a Qt programming question as you are merely asking about c++ syntax
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.
Bookmarks