QtCS25 - QGenericItemModel: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
Ivan.solovev (talk | contribs) |
||
(One intermediate revision by the same user not shown) | |||
Line 1: | Line 1: | ||
==Session Summary== | ==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== | ==Session Owners== | ||
Presenter: Volker | |||
Notes: Ivan | |||
==Notes== | ==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. | |||
[[Category:QtCS2025]] | [[Category:QtCS2025]] |
Latest revision as of 14:58, 8 May 2025
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.