简体   繁体   中英

Qt QModelIndex::sibling return parent QModelIndex

Having a QAbstractItemModel grModel and calling:

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. My expectation is that grSrcIdx1 == grSrcIdx2 .

It seems that the sibling function provides a defaut implementation (or something similar?).

What might be the cause that the sibiling function does not deliver the siblings QModelIndex ? Did I miss to implement a function of the QAbstractItemModel ?

Qt version used is Qt 5.10.0 (MinGw).

The comments of GM and aatwo are the helping ones.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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