PDA

View Full Version : how to initialize an empty QList in the initialization list?



zl2k
19th September 2008, 04:44
hi, there
suppose I define


QList<MyStuff* > list;

in the header file. And I need to initialize an empty list in the initialization list of MyClass. How can I do that?


MyClass::MyClass() : list(0) {...} // won't compile
MyClass::MyClass() : list() {...} // not initialized
MyClass::MyClass() : list() {QList()} // not initialized
//what's the correct way to do that? It's fine if I have to use QList<MyStuff* > * list.

Thanks for help. I'm waiting online.
zl

aamer4yu
19th September 2008, 05:07
Try this
MyClass::MyClass() : list(QList<MyStuff*> ())

zl2k
19th September 2008, 05:21
Y, you are correct, thanks very much.
zl