Hi I have written a small sample, but while its exiting it core dumps. I am using Qt 4.0.1 on Linux. Am I doing anything wrong here? Some body please help, I have attached the source files.
Thanks in advance,
Seem Rao
Hi I have written a small sample, but while its exiting it core dumps. I am using Qt 4.0.1 on Linux. Am I doing anything wrong here? Some body please help, I have attached the source files.
Thanks in advance,
Seem Rao
Problem in your destructor...try first delete list widgets items and then delete list widget..
If it doesnt help try comment delete items.
a life without programming is like an empty bottle
Object that the layers variable points to is owned by the Qt, and Qt will delete it:Originally Posted by Seema Raovoid QLayout::addItem ( QLayoutItem * item ) [pure virtual]
Implemented in subclasses to add an item. How it is added is specific to each subclass.
The ownership of item is transferred to the layout, and it's the layout's responsibility to delete it.You didn't allocate that array using new[], so you can't delete it.Originally Posted by Seema Rao
Then Why is that even if I remove the delete statements sample still cores??
Because you add each item to the list twice:Remove the second line from that for loop and everything should be OK.Qt Code:
... for (int i=0;i<=NumItems; i++){ layers_item[i]->setCheckState(Qt::Unchecked); layers->addItem(layers_item[i]); // <-- and here }To copy to clipboard, switch view to plain text mode
Seema Rao (2nd May 2006)
I have further problems inserting the same QListWidget to a grid Layout.
My sample core dumps before showing the dialog. Can some body please help I have attached the source files. If I comment QListWidgetItem initialization part app does come up. Am I doing anything wrong here ?
Thanks in advance,
Seema
The item array has a size of 19 and you are inserting/indexing 20 items.
Qt Code:
NumItems = 20 // tour.h (36) for (int i=0; i < NumItems; i++) // tour.cpp (104)To copy to clipboard, switch view to plain text mode
J-P Nurmi
Bookmarks