File: pyqt_qvariant.rst

package info (click to toggle)
python-qt4 4.11.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 39,748 kB
  • ctags: 6,146
  • sloc: python: 125,938; cpp: 12,612; xml: 292; makefile: 258; php: 27; sh: 27
file content (18 lines) | stat: -rw-r--r-- 785 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Python Objects and QVariant
===========================

Qt uses the ``QVariant`` class as a wrapper for any C++ data type.  PyQt4
allows any Python object to be wrapped as a ``QVariant`` and passed around Qt's
meta-object system like any other type.

PyQt4 will try to convert the Python object to a C++ equivalent if it can so
that the ``QVariant`` can be passed to other C++ code that doesn't know what a
Python object is.

Version 2 of PyQt4's ``QVariant`` API will automatically convert a ``QVariant``
back to a Python object of the correct type.

Version 1 of the ``QVariant`` API provides the ``QVariant.toPyObject()`` method
to convert the ``QVariant`` back to a Python object of the correct type.

Both versions will raise a Python exception if the conversion cannot be done.