#1248
Support QList<T> even if T does not implement operator==()
Some QLists in Qt have value types that do not implement equality. As specified in QList's documentation, if the value type of a QList does not implement ==, then the following functions are disabled:
containscountindexOflastIndexOf!===
Of those, we use contains and indexOf. One option here would be to have an additional trait for list element value types with equality, and then the QList implementation would use e.g.
pub fn contains(&self, value: &T) -> bool
where
T: QListElementEq,
{
T::contains(self, value)
}At present, the workaround for the issue is to do something like this:
impl QListElement for MyType {
fn contains(list: &QList<Self>, value: &Self) -> bool {
false
}
fn index_of(list: &QList<Self>, value: &Self) -> isize {
-1
}
}Obviously, that's not great.
I think we could also add
whereclauses to these functions.We have done this before e.g. here: https://github.com/KDAB/cxx-qt/blob/fb83a896afb6f5fcd8a15d3bbf0ced707044f155/crates/cxx-qt-lib/src/core/qset/mod.rs#L204 .
We could probably do the same with
where T: Eq;to conditionally disable those functions.