Hi, another problem... :S

I have a QScrollArea with a layout set.

In execution, I create some checkboxes, that I add to the lyout.

Qt Code:
  1. QCheckBox* pChk = 0;
  2. for(int i = 0; i < myList.count(); ++i)
  3. {
  4. pChk = new QCheckBox(info);
  5. my_Lyout->addWidget(pChk);
  6. }
To copy to clipboard, switch view to plain text mode 


I have the

ui.my_scrollArea->setLayout(my_Lyout);

in the constructor.

I'd like to destroy all the checkboxes when the destructor is called:

Qt Code:
  1. CAddGroup::~CAddGroup()
  2. {
  3. for(int i = 0; i < my_Lyout->count(); ++i)
  4. {
  5. QLayoutItem* pChk = my_Lyout->itemAt(i);
  6. delete pChk;
  7. pChk = 0;
  8. }
  9.  
  10. delete(ui.my_scrollArea->layout());
  11.  
  12. m_pVLayGroups = 0;
  13. }
To copy to clipboard, switch view to plain text mode 

But delete(ui.m_srcUsers->layout()); gives me an out of memory exception.

any idea?

thanks!