QtCS25 - QGenericItemModel
Jump to navigation
Jump to search
Session Summary
General solution to expose C++ data to QtQuick.
Based on QAbstractItemModel, uses a templated constructor taking a Range by a universal ref (see docs)
Session Owners
Presenter: Volker
Notes: Ivan
Notes
Some live examples:
- Passing data by const & non-const values, references or ptrs.
- Q: Should we forbid passing by value?
- Passing const data by value -> data in the model is still const, even though it's copied internally. Confusing for C++ developers.
- Using different input types
- vector
- Json array
- list of tuples -> representing multi-column data
- QMetaEnumerator
- actual C++20 ranges
- Unbounded ranges
- Q: How to handle that nicely? Do we need fetchMore() for that?
- QList<QList<Gadget>> -> table.
- MultiColumn vs SingleColumn:
- vector of ptrs to MultiColumn -> table
- vector of ptrs to SingleColumn -> list
More questions:
- What if we store pointers? Who takes the ownership when we create an instance from QML?
- That's the why we need second c-tor that takes the Protocol type - see docs for more details.
- How to modify the data that we handled to the model (by ref or ptr) without using the QAIM API?
- Various approaches are possible - TBD.