[Development] Proposal: Deprecating platforms in Qt 5.6 that don't support lambda
André Somers
andre at familiesomers.nl
Fri Feb 20 10:04:31 CET 2015
Bo Thorsen schreef op 20-2-2015 om 09:03:
> Andrés question about how this would change the API is a lot more
> interesting. I so far haven't seen a single case where someone has
> described how access to lambdas might improve the API. If they are
> there, I'd love to see them, because maybe this would teach me
> something I haven't figured out yet.
One example I could come up with as a potential new API is
QSortFilterProxyModel. Currently, it requires subclassing to change the
sort or the filter functions: it supplies protected filterAcceptsRow,
filterAcceptsColumn and lessThan functions. I think that it would be
much more convenient if these filters and the comparator could be
supplied as a function object (a lambda, or a functor, or a std::mem_fn,
anything callable as a function). While this wasn't all that practical
in the past, I think C++/11 makes this much more convenient than
subclassing.
This could of course just be added, instead of replacing. But that would
mean API bloat. Downside of replacing is of course: you break old code.
I think that if we go over the Qt classes, we'll find more examples of
where a subclass or a separate function that you need to write could be
replaced with a more modern API.
André
More information about the Development
mailing list