[Interest] QML Transparent conversion of QVariantList<QVariantList>> of ints

Jason H jhihn at gmx.com
Fri Nov 16 16:54:51 CET 2018


Update: It seems that it's stored correctly, just not printed correctly.
That is to say: lines[0] = [839, 619, 1118, 845], as expected.

> Sent: Friday, November 16, 2018 at 9:58 AM
> From: "Jason H" <jhihn at gmx.com>
> To: "interestqt-project.org" <interest at qt-project.org>
> Subject: [Interest] QML Transparent conversion of QVariantList<QVariantList>> of ints
>
> Creating list of list of ints requires insert:
> QVariantList qlines;
> std::vector<cv::Vec4i> lines;
> ...
> for( size_t i = 0; i < lines.size(); i++ )
> {
>     qlines.insert(qlines.size(), QVariantList{ lines[i][0], lines[i][1], lines[i][2], lines[i][3]}); // lines = [[839, 619, 1118, 845], [763,550,1199,904]]
> }
> //(QVariant(QVariantList, (QVariant(int, 839), QVariant(int, 619), QVariant(int, 1118), QVariant(int, 845))), ...)
> 
> So far so good.
> I then call setProperty("lines", qlines), and read it back in QML:
> 
> onLinesChanged: console.log("LINES:", lines)
> //qml: LINES: [839,619,1118,845,763,550,1199,904, ...]
> Expected:
> //qml: LINES: [[839, 619, 1118, 845], [763,550,1199,904]]
> 
> It seems that whatever conversion code is happening, is using QList::append or << and not the insert line above? Or am I doing something wrong?
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
> 



More information about the Interest mailing list