[英]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 == grSrcIdx1
, grSrcPrtIdx
包含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.