This is a static archive of the Python wiki, which was retired in February 2026 due to lack of usage and the resources necessary to serve it — predominately to bots, crawlers, and LLM companies.
Pages are preserved as they were at the time of archival. For current information, please visit python.org.
If a change to this archive is absolutely needed, requests can be made via the infrastructure@python.org mailing list.

PyQt 4.6+

PyQt-4.6 and greater have a new API called API2 that is the default when run on Python-3.x. The major difference is that QString does not exist in API2; the library uses the native Python3 str type instead.

To keep your code similar on both python3 and python2, you probably want to pick either the old or the new API and then have your code explicitly use that like so:

To pick the old API:

import sip
sip.setapi('QString', 1)

from PyQt4 import QtCore

# This works as the old API has QString
print(QtCore.QString)

To use API2 everywhere:

import sip
sip.setapi('QString', 2)

from PyQt4 import QtCore

# Now QtCore.QString is no longer available -- use python2's unicode type or python3's str type instead

From the pyqt4 reference manual


2026-02-14 16:12