我的 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
我该怎么做才能访问选定的索引?
亲切的问候,莱因哈特