简体   繁体   English

Qt QModelIndex::sibling return parent QModelIndex

[英]Qt QModelIndex::sibling return parent QModelIndex

Having a QAbstractItemModel grModel and calling:拥有一个 QAbstractItemModel grModel并调用:

QModelIndex grSrcPrtIdx = grModel.index( 1, 0 );
QModelIndex grSrcIdx1   = grSrcPrtIdx.sibling( 1, 0 );
QModelIndex grSrcIdx2   = grModel.index( 1, 0, grSrcPrtIdx )  

Results in: grSrcPrtIdx == grSrcIdx1 with grSrcPrtIdx containing the data expected for grSrcPrtIdx while grSrcIdx2 contains the expected data for the sibling.结果: grSrcPrtIdx == grSrcIdx1grSrcPrtIdx包含grSrcIdx2 grSrcPrtIdx同级的预期数据。 My expectation is that grSrcIdx1 == grSrcIdx2 .我的期望是grSrcIdx1 == grSrcIdx2

It seems that the sibling function provides a defaut implementation (or something similar?).似乎兄弟 function 提供了默认实现(或类似的东西?)。

What might be the cause that the sibiling function does not deliver the siblings QModelIndex ?兄弟姐妹 function 不提供兄弟姐妹QModelIndex的原因可能是什么? Did I miss to implement a function of the QAbstractItemModel ?我错过了实现QAbstractItemModel的 function 吗?

Qt version used is Qt 5.10.0 (MinGw).使用的 Qt 版本是 Qt 5.10.0 (MinGw)。

The comments of GM and aatwo are the helping ones. GM和aatwo的评论是有帮助的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM