How to get list results from QVariant #98
-
Hi, I am using pythonQt to embed python code in my C++ code, I create a python function as the example did, but my return value is a list, and I couldn't fetch the list value after calling the function Could you give some idea on how to get the result when the return value is a list? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
This is without any type checking, but I guess the important part is the toList() method. Simply have a look at the interface of QVariant. |
Beta Was this translation helpful? Give feedback.
-
Thank you so much! I tried the toList method before, but I didn't notice
that toInt() is needed to extract the corresponding data type value.
…On Fri, 17 Feb 2023 at 10:34, Uwe Siems ***@***.***> wrote:
QVariantList resultList = result.toList();
int a = resultList[0].toInt();
int b = resultList[1].toInt();
This is without any type checking, but I guess the important part is the
toList() method. Simply have a look at the interface of QVariant.
—
Reply to this email directly, view it on GitHub
<#97 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AGIB7XYB4SZBZ3QVVALXFSLWX5A2BANCNFSM6AAAAAAU5BHPE4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
This is without any type checking, but I guess the important part is the toList() method. Simply have a look at the interface of QVariant.