0

そのように接続されている 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

選択したインデックスにアクセスできるようにするにはどうすればよいですか?

よろしく、ラインハルト

4

0 に答える 0