
Originally Posted by
d_stranz
In lines 2 and 3 of your code, try replacing "QPersistentModelIndex( index )" with just "index"; then you will be invoking the version of
QPersistentModelIndex::operator==() that compares the two wrapped
QModelIndex instances for equality.
Thanks, d_stranz. That is actually how the code was originally written, and it exhibits this behavior as well. I had added the casting to QPersistentModelIndex when debugging the behavior to see if that was the issue, but it was not.
My original debug code looked something like this:
{
if(debugIndex == index)
{
bool itsInThere = true;
}
if(!indexToPlacemarkMap.contains(map_pindex))
{
bool lookupFailed = true;
}
}
foreach(QPersistentModelIndex map_pindex, indexToPlacemarkMap.keys() )
{
QModelIndex debugIndex = QModelIndex(map_pindex);
if(debugIndex == index)
{
bool itsInThere = true;
}
if(!indexToPlacemarkMap.contains(map_pindex))
{
bool lookupFailed = true;
}
}
To copy to clipboard, switch view to plain text mode
where I was seeing cases where itsInThere was true but lookupFailed was also true. The fact that I could iterate over the keys but have the contains method fail was what led me to see that there seemed to be a difference in the contains method behavior on the keys QList vs QMultiMap.
Bookmarks