Hot to convert (cast) QHash<int, StructOfQByteArray1AndQbyteArray2> to QHash<int, QByteArray1> with minimum resource cost?
-
ok. let's find out how well do you know C++.
ok we havestruct StructOfQByteArray1AndQbyteArray2 { QByteArray array1; QByteArray array2; }Hot to convert (cast)
QHash<int, StructOfQByteArray1AndQbyteArray2>toQHash<int, QByteArray1>with minimum resource cost?where I want to use this?
when working withQAbstractItemModelI implement methodQHash<int, QByteArray> QAbstractItemModel::roleNames() constbut in app I have more complexQHash<int, StructOfQByteArray1AndQbyteArray2>with some extra data. -
well if u want to avoid copy bytearray
maybe use something like
QHash<int, QByteArray1 *>
and set to point to the real QByteArray1; ? -
well if u want to avoid copy bytearray
maybe use something like
QHash<int, QByteArray1 *>
and set to point to the real QByteArray1; ? -
Hi,
From a C++ POV: you can't do such a cast.
What resources do you want to optimize ? Speed ? Memory use ?
-
Hi,
From a C++ POV: you can't do such a cast.
What resources do you want to optimize ? Speed ? Memory use ?
-
I'm just saying that you can't cast (as in static_cast, dynamic_cast etc.) such a hash of int and struct to a hash of int and QByteArray.
Are your role names going to be dynamically created ? Changed ?
-
I'm just saying that you can't cast (as in static_cast, dynamic_cast etc.) such a hash of int and struct to a hash of int and QByteArray.
Are your role names going to be dynamically created ? Changed ?
-
Ok but these roles are already known, no ?