Python list and Qvariant

Source: Internet
Author: User

The PYQT. To pass a list parameter to the SetData function of Qabstracttablemodel:

[20, ' 00:00:19 ']


involves the conversion of qvariant and list.

The ability to use Topyobject in the Qvariant class is a transform.


The environment is: Python 2.7.6 pyqt4 4.8.6

There are articles saying yes. Topyobject can only convert strings, and can only convert dictionaries.


Test it. Supports numbers, dictionaries and lists.


#coding: Utf-8from pyqt4.qtcore import qvarianta={2: ' Ten ', 3: ' 00:00:09 '}aa=qvariant (a) b=aa.topyobject () print bprint (b [2],b[3]) #切割线print (' * ' *8) a=[20, ' 00:00:19 ']aa=qvariant (a) b=aa.topyobject () print bprint (b[0], b[1])



Result diagram:



Passing once. You need to use Qvariant to encapsulate the list. Ability to use the Topyobject () function in the back.

After conversion, you can directly index the required values.


Python list and Qvariant

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.