Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.5.3, 6.6.1
-
None
Description
In Qt5, I was able to create a Q_GADGET wrapper around data types for a non-Qt data stream. This allowed me to move data around using Qt Remote Objects and visualize it in QML.
Raw data stream --> Qt preprocessing app --> QtRO --> HMI App
Looking at porting to Qt6, I'm hitting issues due to changes in qmetatypes.h and the new qiterable.h, specifically for arrays of elements.
I can't change the underlying data stream, so in Qt5, I cast (for instance) a uint8_t array (`uint8_t values[10]`) to `std::array<uint8_t, 10>`, then use `Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE` and `qRegisterMetaType`. This works in Qt5 (with one needed hack*).
In Qt6, this fails asserts in qiterable.h (same assert on line 49 as well).
The root cause appears to be using `QConstPreservingPointer<void, quint16>` from line 417, which uses quint16 for Storage. I guess std::vector and std::list (the types Qt applies Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE to by default) have alignof() size of pointer, but std::array provides alignof() size of the underlying type (1 for uint8_t), which fails the assert.
It is unclear to me why quint16 is needed for Storage here (and not needed in Qt5), so am I not sure how to work around this issue.
*The hack is that Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE expects a SINGLE_ARG_TEMPLATE, so I need to define
template<class T>
using array10 = std::array<T, 10>;
Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(array10)
This doesn't affect the bug, but explains why it is present in the minimal example attached.