qt slot for selectionChanged selectedIndexes DEBUG_ASSERION_FAILED

时间:2014-03-04 08:13:19

标签: qt selectionchanged selectionmodel

我的Qt 4.8插槽有问题,这是以这种方式连接的:

connect(ui->objectTree->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(syncGuiWithTreeSelection(const QItemSelection&, const QItemSelection&)));

插槽有这个签名:

void MyClass::syncGuiWithTreeSelection(const QItemSelection &itemSelected, const QItemSelection &itemDeselected)

在上面的插槽中,我想访问所选的索引:

const QModelIndexList &indexes = itemSelected.indexes();

哪个很好用但是在插槽的末尾,当调用QModelIndexList的析构函数时,会显示DEBUG_ASSERTION_FAILURE。调用堆栈看起来像这样:

msvcr90d.dll!operator delete(void * pUserData=0x03673968)  Line 52 + 0x51 bytes C++
MyClass.exe!QModelIndex::`scalar deleting destructor'()  + 0x32 bytes   C++
MyClass.exe!QList<QModelIndex>::node_destruct(QList<QModelIndex>::Node * from=0x0371c4c4, QList<QModelIndex>::Node * to=0x0371c4c8)  Line 431 + 0x2f bytes  C++
MyClass.exe!QList<QModelIndex>::free(QListData::Data * data=0x0371c4b0)  Line 759   C++
MyClass.exe!QList<QModelIndex>::~QList<QModelIndex>()  Line 733 C++
MyClass.exe!MyClass::syncGuiWithTreeSelection(const QItemSelection & itemSelected={...}, const QItemSelection & itemDeselected={...})  Line 853 + 0xc bytes C++
MyClass.exe!MyClass::qt_static_metacall(QObject * _o=0x001ef69c, QMetaObject::Call _c=InvokeMetaMethod, int _id=49, void * * _a=0x001eca04)  Line 247 + 0x20 by

如何才能访问所选索引?

亲切的问候,重新加入

0 个答案:

没有答案