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