void XXX::slotDelRow(){ QList<QTableWidgetSelectionRange> list = (ui.twList->selectedRanges()); if (!list.isEmpty()) { QTableWidgetSelectionRange ttt = list.first(); int row = ttt.bottomRow(); ui.twList->removeRow(row); }}
---------------------------Microsoft Visual C++ Debug Library---------------------------Debug Assertion Failed!Program: D:\DEVELOP\XXX\XXX.exeFile: f:\dd\vctools\crt_bld\self_x86\crt\src\dbgheap.cLine: 1322Expression: _CrtIsValidHeapPointer(pUserData)For information on how your program can cause an assertionfailure, see the Visual C++ documentation on asserts.
msvcr100d.dll!_CrtIsValidHeapPointer(const void * pUserData=0x00ca2ff0) Line 2036 C++ msvcr100d.dll!_free_dbg_nolock(void * pUserData=0x00ca2ff0, int nBlockUse=1) Line 1322 + 0x9 bytes C++ msvcr100d.dll!_free_dbg(void * pUserData=0x00ca2ff0, int nBlockUse=1) Line 1265 + 0xd bytes C++ msvcr100d.dll!operator delete(void * pUserData=0x00ca2ff0) Line 54 + 0x10 bytes C++> XXX.exe!QTableWidgetSelectionRange::`scalar deleting destructor'() + 0x21 bytes C++ XXX.exe!QList<QTableWidgetSelectionRange>::node_destruct(QList<QTableWidgetSelectionRange>::Node * from=0x00c74174, QList<QTableWidgetSelectionRange>::Node * to=0x00c74174) Line 431 + 0x2f bytes C++ XXX.exe!QList<QTableWidgetSelectionRange>::free(QListData::Data * data=0x00c74160) Line 759 C++ XXX.exe!QList<QTableWidgetSelectionRange>::~QList<QTableWidgetSelectionRange>() Line 733 C++ XXX.exe!XXX::slotDelRow() Line 37 C++
void XXX::slotDelRow(){ ui.twList->removeRow(1);}
QList<QTableWidgetSelectionRange> list = (ui.twList->selectedRanges()); list.clear();
XXX::XXX(QWidget *parent, Qt::WFlags flags) : QDialog(parent, flags){ ui.setupUi(this); connect(this->ui.btnAdd, SIGNAL(clicked()), SLOT(slotAdd())); connect(this->ui.btnDelRow, SIGNAL(clicked()), SLOT(slotDelRow()));}XXX::~XXX(){}void XXX::slotAdd(){ for(int row=0; row!=ui.twList->rowCount(); ++row) { for(int column=0; column!=(ui.twList->columnCount()); ++column) { QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg((row+1)*(column+1))); ui.twList->setItem(row, column, newItem); } }}void XXX::slotDelRow(){ QList<QTableWidgetSelectionRange> list = (ui.twList->selectedRanges()); if (!list.isEmpty()) { QTableWidgetSelectionRange* ttt = &list.first(); int row = ttt->bottomRow(); ui.twList->removeRow(row); } }
QList<QTableWidgetSelectionRange> list = (ui.twList->selectedRanges());list.clear();