Thanks for helping, I've tried to allocate the size of using the value from at line 41, then initiate each nested list with pointers(line 44) that has many items(say 1000), however, the program still crashed.....
Thanks for helping, I've tried to allocate the size of using the value from at line 41, then initiate each nested list with pointers(line 44) that has many items(say 1000), however, the program still crashed.....
If you make listVector a QList (not QList *) member variable of your SNP_Plotter class, then you can use QList::push_back() to add new elements onto the the end of the list.
Your logical error is in thinking that when you allocate a pointer, that also allocates a size for whatever list that is. It doesn't. All it does is allocate a pointer to a list. There is no list, just a pointer to a list. If you want to put things on the list, then you have to use list->push_back() or a similar method. And if what you have allocated is a pointer to a list of pointers to lists, then you have to make sure that what you are pushing onto the main list is pointers to lists that have been allocated with new() and not pointers to things you have created on the stack (e.g. list->push_back( &stackList); ). That will cause a crash too, because those stack things will be deleted as soon as the method that creates them exits and your stack will contain a bunch of pointers to deleted objects.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Bookmarks