1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
|
PyQt4 and Python v3
===================
PyQt4 fully supports all versions of Python v3. The default behaviour is
different in some areas to the default behaviour with Python v2. These
incompatible differences were introduced in order to make PyQt4 more Pythonic.
However it is very easy to revert to the default Python v2 behaviour on a class
by class basis if required. (See the section :ref:`ref-incompat-apis`.)
QAbstractSpinBox
----------------
The following PyQt4 calls have changed signatures to avoid the need for mutable
strings::
QAbstractSpinBox.fixup(str input) -> str
QAbstractSpinBox.validate(str input, int pos) -> QValidator.State, str, int
QChar
-----
The ``QChar`` class is implemented as a mapped type that is automatically
converted to and from a Python string.
QClipboard
----------
The following PyQt4 call has a changed signature to avoid the need for mutable
strings::
QClipboard.text(str subtype, QClipboard.Mode mode=QClipboard.Clipboard) -> str, str
QDate
-----
The ``QDate.__hash__()`` returns a hash of the string representation so that
two objects with the same date will have the same hash.
The default behaviour with Python v2 is to return the object's ``id()`` so that
two objects with the same date will have different hashes.
QDateTime
---------
The ``QDateTime.__hash__()`` method returns a hash of the string representation
so that two objects with the same date and time will have the same hash.
The default behaviour with Python v2 is to return the object's ``id()`` so that
two objects with the same date and time will have different hashes.
QDateTimeEdit
-------------
The following PyQt4 calls have changed signatures to avoid the need for mutable
strings::
QDateTimeEdit.fixup(str input) -> str
QDateTimeEdit.validate(str input, int pos) -> QValidator.State, str, int
QDoubleSpinBox
--------------
The following PyQt4 calls have changed signatures to avoid the need for mutable
strings::
QDoubleSpinBox.fixup(str input) -> str
QDoubleSpinBox.validate(str input, int pos) -> QValidator.State, str, int
QDoubleValidator
----------------
The following PyQt4 call has a changed signature to avoid the need for mutable
strings::
QDoubleValidator.validate(str input, int pos) -> QValidator.State, str, int
QFileDialog
-----------
The following PyQt4 calls have changed signatures to avoid the need for mutable
strings::
QFileDialog.getOpenFileName(QWidget parent=None, str caption=None, str dir=None, str filter=None, QFileDialog.Options options=0) -> str
QFileDialog.getOpenFileNames(QWidget parent=None, str caption=None, str dir=None, str filter=None, QFileDialog.Options options=0) -> list(str)
QFileDialog.getSaveFileName(QWidget parent=None, str caption=None, str dir=None, str filter=None, QFileDialog.Options options=0) -> str
The static methods ``QFileDialog.getOpenFileNameAndFilter()``,
``QFileDialog.getOpenFileNamesAndFilter()`` and
``QFileDialog.getSaveFileNameAndFilter()`` have been added which return a tuple
of the name(s) and the selected filter. These can also be used with Python v2.
QFontMetrics
------------
The methods ``QFontMetrics.widthChar()`` and
``QFontMetrics.boundingRectChar()`` have been added which accept a Python
string of length one and call the C++ ``QFontMetrics::width()`` and
``QFontMetrics::boundingRect()`` methods passing the character as a ``QChar``
(rather than a single character ``QString``).
QFontMetricsF
-------------
The methods ``QFontMetricsF.widthChar()`` and
``QFontMetricsF.boundingRectChar()`` have been added which accept a Python
string of length one and call the C++ ``QFontMetricsF::width()`` and
``QFontMetricsF::boundingRect()`` methods passing the character as a ``QChar``
(rather than a single character ``QString``).
QIntValidator
-------------
The following PyQt4 call has a changed signature to avoid the need for mutable
strings::
QIntValidator.validate(str input, int pos) -> QValidator.State, str, int
QLatin1Char
-----------
The ``QLatin1Char`` class is not implemented.
QLatin1String
-------------
The ``QLatin1String`` class is not implemented.
QPyNullVariant
--------------
The ``QPyNullVariant`` class is used to represent a null ``QVariant``. It is
automatically converted to a C++ ``QVariant`` when required.
A null C++ ``QVariant`` is automatically converted to a ``QPyNullVariant``
unless the type of the data in the ``QVariant`` itself supports the concept of
a null value (i.e. it has an ``isNull()`` method). In this case a null C++
``QVariant`` is converted to a null instance of the data type. The exception
to this rule is that a C++ ``QVariant`` containing a null ``QString`` is always
converted to a ``QPyNullVariant``.
QRegExpValidator
----------------
The following PyQt4 call has a changed signature to avoid the need for mutable
strings::
QRegExpValidator.validate(str input, int pos) -> QValidator.State, str, int
QSettings
---------
The ``QSettings.value()`` method takes an optional ``type`` keyword argument
that specifies the type of the value to return. It can either be a Python type
object or a string specifying the name of a C++ type.
Using this argument avoids potential portability problems where the type of a
value may not be as expected because the platform specific backend to
``QSettings`` may not store the necessary type information.
The argument can also be used with Python v2.
QSpinBox
--------
The following PyQt4 calls have changed signatures to avoid the need for mutable
strings::
QSpinBox.fixup(str input) -> str
QSpinBox.validate(str input, int pos) -> QValidator.State, str, int
QString
-------
The ``QString`` class is implemented as a mapped type that is automatically
converted to and from a Python string. In addition a ``None`` is converted to
a null ``QString``. However, a null ``QString`` is converted to an empty
Python string (and not ``None``). (This is because Qt often returns a null
``QString`` when it should probably return an empty ``QString``.)
QStringList
-----------
The ``QStringList`` class is implemented as a mapped type that is
automatically converted to and from a Python list of strings.
QStringMatcher
--------------
The ``QStringMatcher`` class is not implemented.
QStringRef
----------
The ``QStringRef`` class is implemented as a mapped type that is automatically
converted to and from a Python string.
QTextDecoder
------------
The following C++ call is not wrapped because it expects ``QString`` to be
mutable::
void toUnicode(QString *target, const char *chars, int len)
QTextStream
-----------
The C++ functions ``bin()``, ``hex()`` and ``oct()`` are named ``bin_()``,
``hex_()`` and ``oct_()`` respectively in Python. This allows the import
style ``from PyQt4.QtCore import *`` to be used without them clashing with the
Python built-in functions with the same names.
The following C++ calls are not wrapped because they expect ``QString`` to be
mutable::
QTextStream(QString *string, QIODevice::OpenMode openMode = QIODevice::ReadWrite)
void setString(QString *string, QIODevice::OpenMode openMode = QIODevice::ReadWrite)
QString *string()
QTextStream &operator>>(QChar &c)
QTextStream &operator>>(QString &s)
QTime
-----
The ``QTime.__hash__()`` returns a hash of the string representation so that
two objects with the same time will have the same hash.
The default behaviour with Python v2 is to return the object's ``id()`` so that
two objects with the same time will have different hashes.
QUrl
----
The ``QUrl.__hash__()`` method returns a hash of the string representation so
that two objects with the same URL will have the same hash.
The default behaviour with Python v2 is to return the object's ``id()`` so that
two objects with the same URL will have different hashes.
QValidator
----------
The following PyQt4 calls have changed signatures to avoid the need for mutable
strings::
QValidator.fixup(str input) -> str
QValidator.validate(str input, int pos) -> QValidator.State, str, int
QVariant
--------
The ``QVariant`` class is implemented as a mapped type. Any Python object can
be passed when a ``QVariant`` instance is expected. When Qt returns a
``QVariant`` then it will automatically be converted to the original Python
object or an equivalent.
``None`` is interpreted as an invalid ``QVariant`` and vice versa.
The ``QPyNullVariant`` class is used to represent a null ``QVariant``.
QWebPage
--------
The following PyQt4 call has a changed signature to avoid the need for mutable
strings::
QWebPage.javaScriptPrompt(QWebFrame originatingFrame, str msg, str defaultValue) -> bool, str
QXmlStreamWriter
----------------
The following C++ call is not wrapped because it expects ``QString`` to be
mutable::
QXmlStreamWriter(QString *string)
|