How to get list results from QVariant #98
Answered byusiems
RuoyanMeng asked this question in Q&A
-
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? |
BetaWas this translation helpful?Give feedback.
Answered by usiems Feb 17, 2023
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. |
BetaWas this translation helpful?Give feedback.
0 replies
Answer selected bymrbean-bremen
-
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: ***@***.***> |
BetaWas this translation helpful?Give feedback.
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
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.