Qt.py


NameQt.py JSON
Version 1.4.1 PyPI version JSON
download
home_pagehttps://github.com/mottosso/Qt
SummaryPython 2 & 3 compatibility wrapper around all Qt bindings - PySide, PySide2, PyQt4 and PyQt5.
upload_time2024-05-15 06:30:07
maintainerNone
docs_urlNone
authorMarcus Ottosson
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <img width=260 src=https://raw.githubusercontent.com/mottosso/Qt.py/master/logo.svg>

[![Downloads](https://pepy.tech/badge/qt-py)](https://pepy.tech/project/qt-py)
[![Run Tests](https://github.com/mottosso/Qt.py/actions/workflows/run-tests.yml/badge.svg)](https://github.com/mottosso/Qt.py/actions)
[![PyPI version](https://badge.fury.io/py/Qt.py.svg)](https://pypi.python.org/pypi/Qt.py)
[![Anaconda-Server Badge](https://anaconda.org/conda-forge/qt.py/badges/version.svg)](https://anaconda.org/conda-forge/qt.py)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Qt-py/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)

Qt.py enables you to write software that runs on any of the 4 supported bindings - PySide2, PyQt5, PySide and PyQt4.

<br>

##### News

| Date     | Version   | Event
|:---------|:----------|:----------
| May 2024 | [1.4.0][] | Added support for Qt 6
| Jan 2024 | [1.3.9][] | Run CI on Github Actions, instead of Travis CI.
| Sep 2020 | [1.3.0][] | Stability improvements and greater ability for `QtCompat.wrapInstance` to do its job
| Jun 2019 | [1.2.1][] | Bugfixes and [additional members](https://github.com/mottosso/Qt.py/releases/tag/1.2.0)
| Jan 2018 | [1.1.0][] | Adds new test suite, new members
| Mar 2017 | [1.0.0][] | Increased safety, **backwards incompatible**
| Sep 2016 | [0.6.9][] | Stable release
| Sep 2016 | [0.5.0][] | Alpha release of `--convert`
| Jun 2016 | [0.2.6][] | First release of Qt.py

- [More details](https://github.com/mottosso/Qt.py/releases).

[0.2.6]: https://github.com/mottosso/Qt.py/releases/tag/0.2.6
[0.5.0]: https://github.com/mottosso/Qt.py/releases/tag/0.5.0
[0.6.9]: https://github.com/mottosso/Qt.py/releases/tag/0.6.9
[1.0.0]: https://github.com/mottosso/Qt.py/releases/tag/1.0.0
[1.1.0]: https://github.com/mottosso/Qt.py/releases/tag/1.1.0
[1.2.1]: https://github.com/mottosso/Qt.py/releases/tag/1.2.1
[1.3.0]: https://github.com/mottosso/Qt.py/releases/tag/1.3.0
[1.3.9]: https://github.com/mottosso/Qt.py/releases/tag/1.3.9
[1.4.0]: https://github.com/mottosso/Qt.py/releases/tag/1.4.0

##### Guides

- [Qt 6 Transition Guide](#qt-6-transition-guide)
- [Developing with Qt.py](https://fredrikaverpil.github.io/blog/2016/07/25/developing-with-qtpy/)
- [Dealing with Maya 2017 and PySide2](https://fredrikaverpil.github.io/blog/2016/07/25/dealing-with-maya-2017-and-pyside2/)
- [Vendoring Qt.py](https://fredrikaverpil.github.io/blog/2017/05/04/vendoring-qtpy/)
- [Udemy Course](https://www.udemy.com/python-for-maya/learn/v4/t/lecture/6027394)
- [PythonBytes #77](https://pythonbytes.fm/episodes/show/77/you-don-t-have-to-be-a-workaholic-to-win) (Starts at 5:00)

##### Table of contents

- [Project goals](#project-goals)
- [Install](#install)
- [Usage](#usage)
- [Documentation](#documentation)
  - [Environment Variables](#environment-variables)
  - [Subset](#subset)
  - [Branch binding-specific code](#branch-binding-specific-code)
  - [Override preferred choice](#override-preferred-choice)
  - [QtSiteConfig.py](#qtsiteconfigpy)
  - [Compile Qt Designer files](#compile-qt-designer-files)
  - [Loading Qt Designer files](#loading-qt-designer-files)
  - [sip API v2](#sip-api-v2)
- [Rules](#rules)
- [How it works](#how-it-works)
- [Known problems](#known-problems)
- [Who's using Qt.py?](#whos-using-qtpy)
- [Projects using Qt.py](#projects-using-qtpy)
- [Projects similar to Qt.py](#projects-similar-to-qtpy)
- [Developer guide](#developer-guide)
- [Qt 6 transition guide](#qt-6-transition-guide)

<br>
<br>
<br>

### Project goals

Write once, run in any binding.

Qt.py was born in the film and visual effects industry to address the growing need for software capable of running with more than one flavor of the Qt bindings for Python - PySide, PySide2, PyQt4 and PyQt5.

| Goal                                 | Description
|:-------------------------------------|:---------------
| *Support co-existence*               | Qt.py should not affect other bindings running in same interpreter session.
| *Build for one, run with all*        | Code written with Qt.py should run on any binding.
| *Explicit is better than implicit*   | Differences between bindings should be visible to you.

See [`CONTRIBUTING.md`](CONTRIBUTING.md) for more details.

<br>
<br>
<br>

### Install

Qt.py is a single file and can either be [copy/pasted](https://raw.githubusercontent.com/mottosso/Qt.py/master/Qt.py) into your project, [downloaded](https://github.com/mottosso/Qt.py/archive/master.zip) as-is, cloned as-is or installed via `pip` or `conda`.

```bash
# From PyPI
$ pip install Qt.py
```

```bash
# From Anaconda
$ conda config --add channels conda-forge
$ conda install qt.py
```

- Pro tip: **Never use the latest commit for production**. Instead, use [the latest release](https://github.com/mottosso/Qt.py/releases). That way, when you read bug reports or make one for yourself you will be able to match a version with the problem without which you will not know which fixes apply to you nor would we be able to help you. Installing via pip or conda as above ensures you are provided the latest *stable* release. Unstable releases are suffixed with a `.b`, e.g. `1.1.0.b3`.
- Pro tip: Supports [vendoring](https://fredrikaverpil.github.io/blog/2017/05/04/vendoring-qtpy/)

<br>
<br>
<br>

### Usage

Use Qt.py as you would use PySide2.

![image](https://cloud.githubusercontent.com/assets/2152766/15653248/b5ce298e-2683-11e6-8c0c-f041ecae203d.png)

```python
import sys
from Qt import QtWidgets

app = QtWidgets.QApplication(sys.argv)
button = QtWidgets.QPushButton("Hello World")
button.show()
app.exec_()
```

- Also see [/examples](examples)

<br>
<br>
<br>

### Documentation

All members of `Qt` stem directly from those available via PySide2, along with these additional members.

| Attribute               | Returns     | Description
|:------------------------|:------------|:------------
| `__version__`           | `str`       | Version of this project
| `__binding__`           | `str`       | A string reference to binding currently in use
| `__qt_version__`        | `str`       | Reference to version of Qt, such as Qt 5.6.1
| `__binding_version__`   | `str`       | Reference to version of binding, such as PySide 1.2.6

**Example**

```python
>>> from Qt import __binding__
>>> __binding__
'PyQt5'
```

### Compatibility

Qt.py also provides compatibility wrappers for critical functionality that differs across bindings, these can be found in the added `QtCompat` submodule.

| Attribute                                 | Returns     | Description
|:------------------------------------------|:------------|:------------
| `loadUi(uifile=str, baseinstance=QWidget)`| `QObject`   | Minimal wrapper of PyQt4.loadUi and PySide equivalent
| `translate(...)`        					| `function`  | Compatibility wrapper around [QCoreApplication.translate][]
| `wrapInstance(addr=long, type=QObject)`   | `QObject`   | Wrapper around `shiboken2.wrapInstance` and PyQt equivalent
| `getCppPointer(object=QObject)`           | `long`      | Wrapper around `shiboken2.getCppPointer` and PyQt equivalent
| `isValid(object=QObject)`                 | `bool`      | Wrapper around `shiboken2.isValid` and PyQt equivalent
| `dataChanged(topLeft=QModelIndex, bottomRight=QModelIndex, roles=[])` | `None` | Wrapper around `QtCore.QAbstractItemModel.dataChanged.emit`

[QCoreApplication.translate]: https://doc.qt.io/qt-5/qcoreapplication.html#translate

**Example**

```python
>>> from Qt import QtCompat
>>> QtCompat.loadUi
```

#### Class specific compatibility objects

Between Qt4 and Qt5 there have been many classes and class members that are obsolete. Under Qt.QtCompat there are many classes with names matching the classes they provide compatibility functions. These will match the PySide2 naming convention.

```python
from Qt import QtCore, QtWidgets, QtCompat
header = QtWidgets.QHeaderView(QtCore.Qt.Horizontal)
QtCompat.QHeaderView.setSectionsMovable(header, False)
movable = QtCompat.QHeaderView.sectionsMovable(header)
```

This also covers inconsistencies between bindings. For example PyQt4's QFileDialog matches Qt4's return value of the selected. While all other bindings return the selected filename and the file filter the user used to select the file. `Qt.QtCompat.QFileDialog` ensures that getOpenFileName(s) and getSaveFileName always return the tuple.

<br>

##### Environment Variables

These are the publicly facing environment variables that in one way or another affect the way Qt.py is run.

| Variable                  | Type  | Description
|:--------------------------|:------|:----------
| QT_PREFERRED_BINDING_JSON | str   | Override order and content of binding to try. This can apply per Qt.py namespace.
| QT_PREFERRED_BINDING      | str   | Override order and content of binding to try. Used if QT_PREFERRED_BINDING_JSON does not apply.
| QT_VERBOSE                | bool  | Be a little more chatty about what's going on with Qt.py
| QT_SIP_API_HINT           | int   | Sets the preferred SIP api version that will be attempted to set.

<br>

##### Subset (or "common members")

Members of Qt.py is a subset of PySide2. Which means for a member to be made accessible via Qt.py, it will need to (1) be accessible via PySide2 and (2) each of the other supported bindings. This excludes large portions of the Qt framework, including the newly added QtQml and QtQuick modules but guarantees that anything you develop with Qt.py will work identically on any binding - PySide, PySide2, PyQt4 and PyQt5. If you need to use such excluded modules with Qt.py, please see [QtSiteConfig.py](#qtsiteconfigpy).

We call this subset "common members" and these can be generated by running the `build_membership.sh` script. The script will output all modules and members of each binding into individual JSON files. These JSON files are then compared and a `common_members.json` file is generated. The contents of this file is copy-pasted into the `_common_members` dictionary of Qt.py. Please note that the script will only use the very latest version of our [Docker test suite](DOCKER.md) to generate the common members subset, using the most up-to-date set of VFX Platform-stipulated software versions.

:warning: The version of PySide2 used as reference is the one specified on [VFX Platform](http://www.vfxplatform.com/), currently version is 2.0.x. But unfortunately, the version string of PySide2 is not yet properly maintained and the VFX Platform does not specifiy a explicit commit SHA for PySide2. Therefore, it could be difficult to know exactly which PySide2 is running on your system (unless you built it from source). In layman's terms; as PySide2 is in development and is continuously adding new support for modules, you may see differences between PySide2 built early in the year vs PySide2 built later in the year. The exact commit SHAs of PySide2 used by the Qt.py test suite can be reviewed in [DOCKER.md](DOCKER.md). QtC implemented an alternative way to identify which version of PySide2 you are running. You can read more about that [here](https://codereview.qt-project.org/#/c/202199/).

<br>

##### Branch binding-specific code

Some bindings offer features not available in others, you can use `__binding__` to capture those.

```python
if "PySide" in __binding__:
  do_pyside_stuff()
```

<br>

##### Override preferred choice

If your system has multiple choices where one or more is preferred, you can override the preference and order in which they are tried with this environment variable.

```bash
$ set QT_PREFERRED_BINDING=PyQt5  # Windows
$ export QT_PREFERRED_BINDING=PyQt5  # Unix/OSX
$ python -c "import Qt;print(Qt.__binding__)"
PyQt5
```

Constrain available choices and order of discovery by supplying multiple values.

```bash
# Try PyQt4 first and then PySide, but nothing else.
$ export QT_PREFERRED_BINDING=PyQt4:PySide
```

Using the OS path separator (`os.pathsep`) which is `:` on Unix systems and `;` on Windows.

If you need to control the preferred choice of a specific vendored Qt.py you can use the `QT_PREFERRED_BINDING_JSON` environment variable instead.

```json
{
    "Qt":["PyQt5"],
    "myproject.vendor.Qt":["PyQt5"],
    "default":["PySide2"]
}
```

This json data forces any code that uses `import Qt` or `import myproject.vendor.Qt` to use PyQt5(`from x import Qt` etc works too, this is based on `__name__` of the Qt.py being imported). Any other imports of a Qt module will use the "default" PySide2 only. If `"default"` is not provided or a Qt.py being used does not support `QT_PREFERRED_BINDING_JSON`, `QT_PREFERRED_BINDING` will be respected.

```bash
# Try PyQt5 first and then PyQt4 for the Qt module name space.
$ export QT_PREFERRED_BINDING_JSON="{"Qt":["PyQt5","PyQt4"]}"
# Use PyQt4 for any other Qt module name spaces.
$ export QT_PREFERRED_BINDING=PySide2
```

<br>

##### QtSiteConfig.py

Add or remove members from Qt.py at run-time.

-  [Examples](/examples/QtSiteConfig)

<br>

If you need to expose a module that isn't included in Qt.py by default or wish to remove something from being exposed in Qt.py you can do so by creating a `QtSiteConfig.py` module and making it available to Python.

1. Create a new file `QtSiteConfig.py`
2. Implement `update_members`
3. Expose to Python

```python
# QtSiteConfig.py
def update_members(members):
    """Called by Qt.py at run-time to modify the modules it makes available.

    Arguments:
        members (dict): The members considered by Qt.py
    """
    members.pop("QtCore")
```

Finally, expose the module to Python.

```bash
$ set PYTHONPATH=/path/to
$ python -c "import Qt.QtCore"
ImportError: No module named Qt.QtCore
```

> Linux and MacOS users, replace `set` with `export`

<br>

##### Compile Qt Designer files

> WARNING - ALPHA FUNCTIONALITY<br>
> See [#132](https://github.com/mottosso/Qt.py/pull/132) for details.

`.ui` files compiled via `pyside2-uic` inherently contain traces of PySide2 - e.g. the line `from PySide2 import QtGui`.

In order to use these with Qt.py, or any other binding, one must first erase such traces and replace them with cross-compatible code.

```bash
$ pyside2-uic my_ui.ui -o my_ui.py
$ python -m Qt --convert my_ui.py
# Creating "my_ui_backup.py"..
# Successfully converted "my_ui.py"
```

Now you may use the file as you normally would, with Qt.py

<br>

##### Loading Qt Designer files

The `uic.loadUi` function of PyQt4 and PyQt5 as well as the `QtUiTools.QUiLoader().load` function of PySide/PySide2 are mapped to a convenience function `loadUi`.

```python
import sys
from Qt import QtCompat

app = QtWidgets.QApplication(sys.argv)
ui = QtCompat.loadUi(uifile="my.ui")
ui.show()
app.exec_()
```
For `PyQt` bindings it uses their native implementation, whereas for `PySide` bindings it uses our custom implementation borrowed from the [qtpy](https://github.com/spyder-ide/qtpy) project.

`loadUi` has two arguments as opposed to the multiple that PyQt ships with. See [here](https://github.com/mottosso/Qt.py/pull/81) for details - in a nutshell, those arguments differ between PyQt and PySide in incompatible ways.
The second argument is `baseinstance` which allows a ui to be dynamically loaded onto an existing QWidget instance.

```python
QtCompat.loadUi(uifile="my.ui", baseinstance=QtWidgets.QWidget)
```

`uifile` is the string path to the ui file to load.

If `baseinstance` is `None`, the a new instance of the top-level
widget will be created. Otherwise, the user interface is created within
the given `baseinstance`. In this case `baseinstance` must be an
instance of the top-level widget class in the UI file to load, or a
subclass thereof. In other words, if you've created a `QMainWindow`
interface in the designer, `baseinstance` must be a `QMainWindow`
or a subclass thereof, too. You cannot load a `QMainWindow` UI file
with a plain `QWidget` as `baseinstance`.

`loadUi` returns `baseinstance`, if `baseinstance` is provided.
Otherwise it will return the newly created instance of the user interface.

<br>

##### sip API v2

If you're using PyQt4, `sip` attempts to set its API to version 2 for the following:
- `QString`
- `QVariant`
- `QDate`
- `QDateTime`
- `QTextStream`
- `QTime`
- `QUrl`

<br>
<br>
<br>

### Rules

The PyQt and PySide bindings are similar, but not identical. Where there is ambiguity, there must to be a clear direction on which path to take.

**Governing API**

The official [Qt 5 documentation](http://doc.qt.io/qt-5/classes.html) is always right. Where the documentation lacks answers, PySide2 is right.

For example.

```python
# PyQt5 adheres to PySide2 signals and slots
PyQt5.Signal = PyQt5.pyqtSignal
PyQt5.Slot = PyQt5.pyqtSlot

# PySide2 adheres to the official documentation
PySide2.QtCore.QStringListModel = PySide2.QtGui.QStringListModel
```

**Caveats**

There are cases where Qt.py is not handling incompatibility issues. Please see [`CAVEATS.md`](CAVEATS.md) for more information.

<br>
<br>
<br>

### Known Problems

Send us a pull-request with known problems here!

- [Maya and incompatible bindings on PYTHONPATH](https://github.com/mottosso/Qt.py/issues/146)

<br>
<br>
<br>

### Who's using Qt.py?

Send us a pull-request with your studio here.

- [Atomic Fiction](http://www.atomicfiction.com/)
- [Bläck](http://www.blackstudios.se/)
- [Blur Studio](http://www.blur.com)
- [CGRU](http://cgru.info/)
- [Colorbleed](http://www.colorbleed.nl/)
- [Digital Domain](https://www.digitaldomain.com/)
- [Disney Animation](https://www.disneyanimation.com/)
- [Dreamworks Animation](https://github.com/dreamworksanimation)
- [Epic Games](https://www.epicgames.com/)
- [Fido](http://fido.se/)
- [Framestore](https://framestore.com)
- [ftrack](https://www.ftrack.com/)
- [Futureworks](http://futureworks.in/)
- [Industrial Brothers](http://industrialbrothers.com/)
- [Industriromantik](http://www.industriromantik.se/)
- [Mackevision](http://www.mackevision.com/)
- [Method Studios](http://www.methodstudios.com/)
- [Mikros Image](http://www.mikrosimage.com/)
- [Moonbot Studios](http://moonbotstudios.com/)
- [MPC](http://www.moving-picture.com)
- [Overmind Studios](https://www.overmind-studios.de/)
- [Psyop](http://www.psyop.com/)
- [Raynault VFX](https://www.raynault.com/)
- [Rising Sun Pictures](https://rsp.com.au)
- [Rodeo FX](https://www.rodeofx.com/en/)
- [Sony Pictures Imageworks](http://www.imageworks.com/)
- [Spin VFX](http://www.spinvfx.com/)
- [Weta Digital](https://www.wetafx.co.nz/)

Presented at Siggraph 2016, BOF!

![image](https://cloud.githubusercontent.com/assets/2152766/17621229/c2448db2-6089-11e6-915f-0604e5d8c7ee.png)

<br>
<br>
<br>

### Projects using Qt.py

Send us a pull-request with your project here.

- [USD Manager](http://www.usdmanager.org)
- [Cosmos](http://cosmos.toolsfrom.space/)
- [maya-capture-gui](https://github.com/BigRoy/maya-capture-gui)
- [pyblish-lite](https://github.com/pyblish/pyblish-lite)
- [pyvfx-boilerplate](https://github.com/fredrikaverpil/pyvfx-boilerplate)
- [riffle](https://gitlab.com/4degrees/riffle)
- [cmt](https://github.com/chadmv/cmt)
- [PythonForMayaSamples](https://github.com/dgovil/PythonForMayaSamples)
- [Kraken](https://github.com/fabric-engine/Kraken)
- [AFANASY](http://cgru.info/afanasy/afanasy)
- [Syncplay](https://github.com/Syncplay/syncplay)
- [BlenderUpdater](https://github.com/overmindstudios/BlenderUpdater)
- [QtPyConvert](https://github.com/DigitalDomain/QtPyConvert)
- [Pyper](https://gitlab.com/brunoebe/pyper.git)

<br>
<br>
<br>

### Projects similar to Qt.py

Comparison matrix.

| Project       | Audience      | Reference binding | License   | PEP8 |Standalone | PyPI   | Co-existence
|:--------------|:--------------|:------------------|:----------|------|:----------|--------|--------------
| Qt.py         | Film          | PySide2           | MIT       | X    | X         | X      | X
| [jupyter][]   | Scientific    | N/A               | N/A       | X    |           |        |
| [QtPy][]      | Scientific    | N/A               | MIT       |      | X         | X      |
| [pyqode.qt][] | Scientific    | PyQt5             | MIT       | X    |           | X      |
| [QtExt][]     | Film          | N/A               | N/A       |      | X         |        |
| [python_qt_binding][] | Robotics | N/A            | BSD       | X    | X        | X       | X

Also worth mentioning, [pyqt4topyqt5](https://github.com/rferrazz/pyqt4topyqt5); a good starting point for transitioning to Qt.py.

Send us a pull-request with your project here.

[QtPy]: https://github.com/spyder-ide/qtpy
[jupyter]: https://github.com/jupyter/qtconsole/blob/master/qtconsole/qt_loaders.py
[pyqode.qt]: https://github.com/pyQode/pyqode.qt
[QtExt]: https://bitbucket.org/ftrack/qtext
[python_qt_binding]: https://github.com/ros-visualization/python_qt_binding

<br>
<br>
<br>

### Developer Guide

Tests are performed on each aspect of the shim.

- [Functional](tests.py)
- [Caveats](build_caveats.py)
- [Examples](examples)

Each of these are run under..

- Python 2.7
- Python 3.4
- Python 3.5
- Python 3.6

..once for each binding or under a specific binding only.

Each test is run within it's own isolated process, so as to allow an `import` to occur independently from other tests. Process isolation is handled via [nosepipe](https://pypi.python.org/pypi/nosepipe).

Tests that are written at module level are run four times - once per binding - whereas tests written under a specific if-statement are run only for this particular binding.

```python
if binding("PyQt4"):
    def test_something_related_to_pyqt4():
        pass
```

**Code convention**

Below are some of the conventions that used throughout the Qt.py module and tests.

- **Etiquette: PEP8**
    - All code is written in PEP8. It is recommended you use a linter as you work, flake8 and pylinter are both good options. Anaconda if using Sublime is another good option.
- **Etiquette: Double quotes**
    - " = yes, ' = no.
- **Etiquette: Napoleon docstrings**
    - Any docstrings are made in Google Napoleon format. See [Napoleon](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) for details.
- **Etiquette: Semantic Versioning**
    - This project follows [semantic versioning](http://semver.org).
- **Etiquette: Underscore means private**
    - Anything prefixed with an underscore means that it is internal to Qt.py and not for public consumption.

**Running tests**

Due to the nature of multiple bindings and multiple interpreter support, setting up a development environment in which to properly test your contraptions can be challenging. So here is a guide for how to do just that using **Docker**.

With Docker setup, here's what you do. Please note this will pull down a ~1 GB image.

```bash
cd Qt.py

# Run nosetests (Linux/OSX)
docker run --rm -v $(pwd):/Qt.py -e PYTHON=2.7 fredrikaverpil/qt.py:2018
docker run --rm -v $(pwd):/Qt.py -e PYTHON=3.4 fredrikaverpil/qt.py:2018
docker run --rm -v $(pwd):/Qt.py -e PYTHON=3.5 fredrikaverpil/qt.py:2018
docker run --rm -v $(pwd):/Qt.py -e PYTHON=3.6 fredrikaverpil/qt.py:2018

# Run nosetests (Windows)
docker run --rm -v %CD%:/Qt.py -e PYTHON=2.7 fredrikaverpil/qt.py:2018
docker run --rm -v %CD%:/Qt.py -e PYTHON=3.4 fredrikaverpil/qt.py:2018
docker run --rm -v %CD%:/Qt.py -e PYTHON=3.5 fredrikaverpil/qt.py:2018
docker run --rm -v %CD%:/Qt.py -e PYTHON=3.6 fredrikaverpil/qt.py:2018

# Doctest: test_caveats.test_1_qtgui_qabstractitemmodel_createindex ... ok
# Doctest: test_caveats.test_2_qtgui_qabstractitemmodel_createindex ... ok
# Doctest: test_caveats.test_3_qtcore_qitemselection ... ok
# ...
#
# ----------------------------------------------------------------------
# Ran 21 tests in 7.799s
#
# OK
```

Now both you and Github Actions are operating on the same assumptions which means that when the tests pass on your machine, they pass on Github Actions. And everybody wins!

For details on the Docker image for testing, see [`DOCKER.md`](DOCKER.md).

See [`CONTRIBUTING.md`](CONTRIBUTING.md) for more of the good stuff.

**Upload to PyPI**

To make a new release onto PyPI, you'll need to be mottosso and type this.

```bash
cd Qt.py
python .\setup.py sdist bdist_wheel
python -m twine upload .\dist\*
```

<br>
<br>
<br>

### Qt 6 Transition Guide

| Replace | With | Notes
|:--------|:-----|:----------------------------
| `QFont().setWeight(...)` | `QtCompat.QFont.setWeight(font, ...)`
| `QFont().setWeight(QFont().Bold)` | `QFont().setWeight(QFont.Bold)` | Instance of class doesn't have the enums, apparently
| `QEvent().Resize` | `QEvent.Resize` | Instance of class doesn't have the enums, seems to apply overall
| `QtCore.Qt.MidButton`  | `QtCompat.QtCore.Qt.MidButton`
| `QLabel.setPixmap(str)` | `QLabel.setPixmap(QPixmap())` | Can't take a string anymore (tested in Maya 2025.0)
| `QModelIndex.child` | `QModel.index` | This one is apparently from Qt 4 and should not have been in Qt.py to begin with
| | Submit your known issues here! |

##### Removed Members

Many members were removed from Qt.py due to no longer existing in PySide 6.

> If you find where they went, or think some were removed in error, please submit a pull-request!

```json
"QtCore": [
    "QAbstractState",
    "QAbstractTransition",
    "QEventTransition",
    "QFinalState",
    "QSignalTransition",
    "QTextCodec",
    "QTextDecoder",
    "QTextEncoder",
    "QtCriticalMsg",
    "QtDebugMsg",
    "QtFatalMsg",
    "QtSystemMsg",
    "QtWarningMsg",
    "qChecksum",
    "QPictureIO",
],
"QtMultimedia": [
    "QAbstractVideoBuffer",
    "QAbstractVideoSurface",
    "QAudio",
    "QAudioDeviceInfo",
    "QAudioFormat",
    "QAudioInput",
    "QAudioOutput",
    "QVideoFrame",
    "QVideoSurfaceFormat"
],
"QtNetwork": [
    "QNetworkConfiguration",
    "QNetworkConfigurationManager",
    "QNetworkSession",
],
"QtOpenGL": [
    "QGL",
    "QGLContext",
    "QGLFormat",
    "QGLWidget"
],
"QtSql": [
    "QSql",
    "QSqlDatabase",
    "QSqlDriver",
    "QSqlDriverCreatorBase",
    "QSqlError",
    "QSqlField",
    "QSqlIndex",
    "QSqlQuery",
    "QSqlQueryModel",
    "QSqlRecord",
    "QSqlRelation",
    "QSqlRelationalDelegate",
    "QSqlRelationalTableModel",
    "QSqlResult",
    "QSqlTableModel"
],
"QtSvg": [
    "QSvgGenerator",
    "QSvgRenderer",
],
"QtWidgets": [
    "QActionGroup",
    "QDesktopWidget",
    "QDirModel",
    "QKeyEventTransition",
    "QMouseEventTransition",
    "QUndoCommand",
    "QUndoGroup",
    "QUndoStack",
],
"QtX11Extras": [
    "QX11Info"
],
"QtXml": [
    "QXmlAttributes",
    "QXmlContentHandler",
    "QXmlDTDHandler",
    "QXmlDeclHandler",
    "QXmlDefaultHandler",
    "QXmlEntityResolver",
    "QXmlErrorHandler",
    "QXmlInputSource",
    "QXmlLexicalHandler",
    "QXmlLocator",
    "QXmlNamespaceSupport",
    "QXmlParseException",
    "QXmlReader",
    "QXmlSimpleReader"
],
"QtXmlPatterns": [
    "QAbstractMessageHandler",
    "QAbstractUriResolver",
    "QAbstractXmlNodeModel",
    "QAbstractXmlReceiver",
    "QSourceLocation",
    "QXmlFormatter",
    "QXmlItem",
    "QXmlName",
    "QXmlNamePool",
    "QXmlNodeModelIndex",
    "QXmlQuery",
    "QXmlResultItems",
    "QXmlSchema",
    "QXmlSchemaValidator",
    "QXmlSerializer"
]
```

##### Static Members Missing from Instances

An overall change is that instances of classes, like `QFont()` no longer provides access to static members, such as `QFont.Bold`. So things like:

```py
font = QFont()
font.setWeight(font.Bold)
```

Must be replaced with:

```py
font = QFont()
font.setWeight(QFont.Bold)
```

Or:

```py
font.setWeight(type(font).Bold)
```

Tedious and seemingly unnecessary.. But there you have it!

##### Notes

Qt.py 1.4.0, released in May 2024, added support for Qt 6 whilst preserving compatibility with Qt 4 and 5. That means that in most cases, code you've already written for Qt 4 or 5 will now continue to work with Qt 6, such as Maya 2025.

However, some changes between 5 and 6 require up-front work by you the developer to make your codebase run on Qt 6 whilst continuing to run on Qt 4 and 5.

The above is what we know, please do submit issues and pull-request with what else you find!

- https://github.com/mottosso/Qt.py/issues/new

**See also**

The official PySide2 to PySide6 transition guide, which is especially helpful since Qt.py is modeled after PySide2.

- https://doc.qt.io/qtforpython-6/gettingstarted/porting_from2.html

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mottosso/Qt",
    "name": "Qt.py",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Marcus Ottosson",
    "author_email": "konstruktion@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/cc/97/2f9c8aaa3380624383ddf1dd492ca691d02900cbaa31cfd18ad0cbc85daf/Qt.py-1.4.1.tar.gz",
    "platform": null,
    "description": "<img width=260 src=https://raw.githubusercontent.com/mottosso/Qt.py/master/logo.svg>\n\n[![Downloads](https://pepy.tech/badge/qt-py)](https://pepy.tech/project/qt-py)\n[![Run Tests](https://github.com/mottosso/Qt.py/actions/workflows/run-tests.yml/badge.svg)](https://github.com/mottosso/Qt.py/actions)\n[![PyPI version](https://badge.fury.io/py/Qt.py.svg)](https://pypi.python.org/pypi/Qt.py)\n[![Anaconda-Server Badge](https://anaconda.org/conda-forge/qt.py/badges/version.svg)](https://anaconda.org/conda-forge/qt.py)\n[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Qt-py/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)\n[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)\n\nQt.py enables you to write software that runs on any of the 4 supported bindings - PySide2, PyQt5, PySide and PyQt4.\n\n<br>\n\n##### News\n\n| Date     | Version   | Event\n|:---------|:----------|:----------\n| May 2024 | [1.4.0][] | Added support for Qt 6\n| Jan 2024 | [1.3.9][] | Run CI on Github Actions, instead of Travis CI.\n| Sep 2020 | [1.3.0][] | Stability improvements and greater ability for `QtCompat.wrapInstance` to do its job\n| Jun 2019 | [1.2.1][] | Bugfixes and [additional members](https://github.com/mottosso/Qt.py/releases/tag/1.2.0)\n| Jan 2018 | [1.1.0][] | Adds new test suite, new members\n| Mar 2017 | [1.0.0][] | Increased safety, **backwards incompatible**\n| Sep 2016 | [0.6.9][] | Stable release\n| Sep 2016 | [0.5.0][] | Alpha release of `--convert`\n| Jun 2016 | [0.2.6][] | First release of Qt.py\n\n- [More details](https://github.com/mottosso/Qt.py/releases).\n\n[0.2.6]: https://github.com/mottosso/Qt.py/releases/tag/0.2.6\n[0.5.0]: https://github.com/mottosso/Qt.py/releases/tag/0.5.0\n[0.6.9]: https://github.com/mottosso/Qt.py/releases/tag/0.6.9\n[1.0.0]: https://github.com/mottosso/Qt.py/releases/tag/1.0.0\n[1.1.0]: https://github.com/mottosso/Qt.py/releases/tag/1.1.0\n[1.2.1]: https://github.com/mottosso/Qt.py/releases/tag/1.2.1\n[1.3.0]: https://github.com/mottosso/Qt.py/releases/tag/1.3.0\n[1.3.9]: https://github.com/mottosso/Qt.py/releases/tag/1.3.9\n[1.4.0]: https://github.com/mottosso/Qt.py/releases/tag/1.4.0\n\n##### Guides\n\n- [Qt 6 Transition Guide](#qt-6-transition-guide)\n- [Developing with Qt.py](https://fredrikaverpil.github.io/blog/2016/07/25/developing-with-qtpy/)\n- [Dealing with Maya 2017 and PySide2](https://fredrikaverpil.github.io/blog/2016/07/25/dealing-with-maya-2017-and-pyside2/)\n- [Vendoring Qt.py](https://fredrikaverpil.github.io/blog/2017/05/04/vendoring-qtpy/)\n- [Udemy Course](https://www.udemy.com/python-for-maya/learn/v4/t/lecture/6027394)\n- [PythonBytes #77](https://pythonbytes.fm/episodes/show/77/you-don-t-have-to-be-a-workaholic-to-win) (Starts at 5:00)\n\n##### Table of contents\n\n- [Project goals](#project-goals)\n- [Install](#install)\n- [Usage](#usage)\n- [Documentation](#documentation)\n  - [Environment Variables](#environment-variables)\n  - [Subset](#subset)\n  - [Branch binding-specific code](#branch-binding-specific-code)\n  - [Override preferred choice](#override-preferred-choice)\n  - [QtSiteConfig.py](#qtsiteconfigpy)\n  - [Compile Qt Designer files](#compile-qt-designer-files)\n  - [Loading Qt Designer files](#loading-qt-designer-files)\n  - [sip API v2](#sip-api-v2)\n- [Rules](#rules)\n- [How it works](#how-it-works)\n- [Known problems](#known-problems)\n- [Who's using Qt.py?](#whos-using-qtpy)\n- [Projects using Qt.py](#projects-using-qtpy)\n- [Projects similar to Qt.py](#projects-similar-to-qtpy)\n- [Developer guide](#developer-guide)\n- [Qt 6 transition guide](#qt-6-transition-guide)\n\n<br>\n<br>\n<br>\n\n### Project goals\n\nWrite once, run in any binding.\n\nQt.py was born in the film and visual effects industry to address the growing need for software capable of running with more than one flavor of the Qt bindings for Python - PySide, PySide2, PyQt4 and PyQt5.\n\n| Goal                                 | Description\n|:-------------------------------------|:---------------\n| *Support co-existence*               | Qt.py should not affect other bindings running in same interpreter session.\n| *Build for one, run with all*        | Code written with Qt.py should run on any binding.\n| *Explicit is better than implicit*   | Differences between bindings should be visible to you.\n\nSee [`CONTRIBUTING.md`](CONTRIBUTING.md) for more details.\n\n<br>\n<br>\n<br>\n\n### Install\n\nQt.py is a single file and can either be [copy/pasted](https://raw.githubusercontent.com/mottosso/Qt.py/master/Qt.py) into your project, [downloaded](https://github.com/mottosso/Qt.py/archive/master.zip) as-is, cloned as-is or installed via `pip` or `conda`.\n\n```bash\n# From PyPI\n$ pip install Qt.py\n```\n\n```bash\n# From Anaconda\n$ conda config --add channels conda-forge\n$ conda install qt.py\n```\n\n- Pro tip: **Never use the latest commit for production**. Instead, use [the latest release](https://github.com/mottosso/Qt.py/releases). That way, when you read bug reports or make one for yourself you will be able to match a version with the problem without which you will not know which fixes apply to you nor would we be able to help you. Installing via pip or conda as above ensures you are provided the latest *stable* release. Unstable releases are suffixed with a `.b`, e.g. `1.1.0.b3`.\n- Pro tip: Supports [vendoring](https://fredrikaverpil.github.io/blog/2017/05/04/vendoring-qtpy/)\n\n<br>\n<br>\n<br>\n\n### Usage\n\nUse Qt.py as you would use PySide2.\n\n![image](https://cloud.githubusercontent.com/assets/2152766/15653248/b5ce298e-2683-11e6-8c0c-f041ecae203d.png)\n\n```python\nimport sys\nfrom Qt import QtWidgets\n\napp = QtWidgets.QApplication(sys.argv)\nbutton = QtWidgets.QPushButton(\"Hello World\")\nbutton.show()\napp.exec_()\n```\n\n- Also see [/examples](examples)\n\n<br>\n<br>\n<br>\n\n### Documentation\n\nAll members of `Qt` stem directly from those available via PySide2, along with these additional members.\n\n| Attribute               | Returns     | Description\n|:------------------------|:------------|:------------\n| `__version__`           | `str`       | Version of this project\n| `__binding__`           | `str`       | A string reference to binding currently in use\n| `__qt_version__`        | `str`       | Reference to version of Qt, such as Qt 5.6.1\n| `__binding_version__`   | `str`       | Reference to version of binding, such as PySide 1.2.6\n\n**Example**\n\n```python\n>>> from Qt import __binding__\n>>> __binding__\n'PyQt5'\n```\n\n### Compatibility\n\nQt.py also provides compatibility wrappers for critical functionality that differs across bindings, these can be found in the added `QtCompat` submodule.\n\n| Attribute                                 | Returns     | Description\n|:------------------------------------------|:------------|:------------\n| `loadUi(uifile=str, baseinstance=QWidget)`| `QObject`   | Minimal wrapper of PyQt4.loadUi and PySide equivalent\n| `translate(...)`        \t\t\t\t\t| `function`  | Compatibility wrapper around [QCoreApplication.translate][]\n| `wrapInstance(addr=long, type=QObject)`   | `QObject`   | Wrapper around `shiboken2.wrapInstance` and PyQt equivalent\n| `getCppPointer(object=QObject)`           | `long`      | Wrapper around `shiboken2.getCppPointer` and PyQt equivalent\n| `isValid(object=QObject)`                 | `bool`      | Wrapper around `shiboken2.isValid` and PyQt equivalent\n| `dataChanged(topLeft=QModelIndex, bottomRight=QModelIndex, roles=[])` | `None` | Wrapper around `QtCore.QAbstractItemModel.dataChanged.emit`\n\n[QCoreApplication.translate]: https://doc.qt.io/qt-5/qcoreapplication.html#translate\n\n**Example**\n\n```python\n>>> from Qt import QtCompat\n>>> QtCompat.loadUi\n```\n\n#### Class specific compatibility objects\n\nBetween Qt4 and Qt5 there have been many classes and class members that are obsolete. Under Qt.QtCompat there are many classes with names matching the classes they provide compatibility functions. These will match the PySide2 naming convention.\n\n```python\nfrom Qt import QtCore, QtWidgets, QtCompat\nheader = QtWidgets.QHeaderView(QtCore.Qt.Horizontal)\nQtCompat.QHeaderView.setSectionsMovable(header, False)\nmovable = QtCompat.QHeaderView.sectionsMovable(header)\n```\n\nThis also covers inconsistencies between bindings. For example PyQt4's QFileDialog matches Qt4's return value of the selected. While all other bindings return the selected filename and the file filter the user used to select the file. `Qt.QtCompat.QFileDialog` ensures that getOpenFileName(s) and getSaveFileName always return the tuple.\n\n<br>\n\n##### Environment Variables\n\nThese are the publicly facing environment variables that in one way or another affect the way Qt.py is run.\n\n| Variable                  | Type  | Description\n|:--------------------------|:------|:----------\n| QT_PREFERRED_BINDING_JSON | str   | Override order and content of binding to try. This can apply per Qt.py namespace.\n| QT_PREFERRED_BINDING      | str   | Override order and content of binding to try. Used if QT_PREFERRED_BINDING_JSON does not apply.\n| QT_VERBOSE                | bool  | Be a little more chatty about what's going on with Qt.py\n| QT_SIP_API_HINT           | int   | Sets the preferred SIP api version that will be attempted to set.\n\n<br>\n\n##### Subset (or \"common members\")\n\nMembers of Qt.py is a subset of PySide2. Which means for a member to be made accessible via Qt.py, it will need to (1) be accessible via PySide2 and (2) each of the other supported bindings. This excludes large portions of the Qt framework, including the newly added QtQml and QtQuick modules but guarantees that anything you develop with Qt.py will work identically on any binding - PySide, PySide2, PyQt4 and PyQt5. If you need to use such excluded modules with Qt.py, please see [QtSiteConfig.py](#qtsiteconfigpy).\n\nWe call this subset \"common members\" and these can be generated by running the `build_membership.sh` script. The script will output all modules and members of each binding into individual JSON files. These JSON files are then compared and a `common_members.json` file is generated. The contents of this file is copy-pasted into the `_common_members` dictionary of Qt.py. Please note that the script will only use the very latest version of our [Docker test suite](DOCKER.md) to generate the common members subset, using the most up-to-date set of VFX Platform-stipulated software versions.\n\n:warning: The version of PySide2 used as reference is the one specified on [VFX Platform](http://www.vfxplatform.com/), currently version is 2.0.x. But unfortunately, the version string of PySide2 is not yet properly maintained and the VFX Platform does not specifiy a explicit commit SHA for PySide2. Therefore, it could be difficult to know exactly which PySide2 is running on your system (unless you built it from source). In layman's terms; as PySide2 is in development and is continuously adding new support for modules, you may see differences between PySide2 built early in the year vs PySide2 built later in the year. The exact commit SHAs of PySide2 used by the Qt.py test suite can be reviewed in [DOCKER.md](DOCKER.md). QtC implemented an alternative way to identify which version of PySide2 you are running. You can read more about that [here](https://codereview.qt-project.org/#/c/202199/).\n\n<br>\n\n##### Branch binding-specific code\n\nSome bindings offer features not available in others, you can use `__binding__` to capture those.\n\n```python\nif \"PySide\" in __binding__:\n  do_pyside_stuff()\n```\n\n<br>\n\n##### Override preferred choice\n\nIf your system has multiple choices where one or more is preferred, you can override the preference and order in which they are tried with this environment variable.\n\n```bash\n$ set QT_PREFERRED_BINDING=PyQt5  # Windows\n$ export QT_PREFERRED_BINDING=PyQt5  # Unix/OSX\n$ python -c \"import Qt;print(Qt.__binding__)\"\nPyQt5\n```\n\nConstrain available choices and order of discovery by supplying multiple values.\n\n```bash\n# Try PyQt4 first and then PySide, but nothing else.\n$ export QT_PREFERRED_BINDING=PyQt4:PySide\n```\n\nUsing the OS path separator (`os.pathsep`) which is `:` on Unix systems and `;` on Windows.\n\nIf you need to control the preferred choice of a specific vendored Qt.py you can use the `QT_PREFERRED_BINDING_JSON` environment variable instead.\n\n```json\n{\n    \"Qt\":[\"PyQt5\"],\n    \"myproject.vendor.Qt\":[\"PyQt5\"],\n    \"default\":[\"PySide2\"]\n}\n```\n\nThis json data forces any code that uses `import Qt` or `import myproject.vendor.Qt` to use PyQt5(`from x import Qt` etc works too, this is based on `__name__` of the Qt.py being imported). Any other imports of a Qt module will use the \"default\" PySide2 only. If `\"default\"` is not provided or a Qt.py being used does not support `QT_PREFERRED_BINDING_JSON`, `QT_PREFERRED_BINDING` will be respected.\n\n```bash\n# Try PyQt5 first and then PyQt4 for the Qt module name space.\n$ export QT_PREFERRED_BINDING_JSON=\"{\"Qt\":[\"PyQt5\",\"PyQt4\"]}\"\n# Use PyQt4 for any other Qt module name spaces.\n$ export QT_PREFERRED_BINDING=PySide2\n```\n\n<br>\n\n##### QtSiteConfig.py\n\nAdd or remove members from Qt.py at run-time.\n\n-  [Examples](/examples/QtSiteConfig)\n\n<br>\n\nIf you need to expose a module that isn't included in Qt.py by default or wish to remove something from being exposed in Qt.py you can do so by creating a `QtSiteConfig.py` module and making it available to Python.\n\n1. Create a new file `QtSiteConfig.py`\n2. Implement `update_members`\n3. Expose to Python\n\n```python\n# QtSiteConfig.py\ndef update_members(members):\n    \"\"\"Called by Qt.py at run-time to modify the modules it makes available.\n\n    Arguments:\n        members (dict): The members considered by Qt.py\n    \"\"\"\n    members.pop(\"QtCore\")\n```\n\nFinally, expose the module to Python.\n\n```bash\n$ set PYTHONPATH=/path/to\n$ python -c \"import Qt.QtCore\"\nImportError: No module named Qt.QtCore\n```\n\n> Linux and MacOS users, replace `set` with `export`\n\n<br>\n\n##### Compile Qt Designer files\n\n> WARNING - ALPHA FUNCTIONALITY<br>\n> See [#132](https://github.com/mottosso/Qt.py/pull/132) for details.\n\n`.ui` files compiled via `pyside2-uic` inherently contain traces of PySide2 - e.g. the line `from PySide2 import QtGui`.\n\nIn order to use these with Qt.py, or any other binding, one must first erase such traces and replace them with cross-compatible code.\n\n```bash\n$ pyside2-uic my_ui.ui -o my_ui.py\n$ python -m Qt --convert my_ui.py\n# Creating \"my_ui_backup.py\"..\n# Successfully converted \"my_ui.py\"\n```\n\nNow you may use the file as you normally would, with Qt.py\n\n<br>\n\n##### Loading Qt Designer files\n\nThe `uic.loadUi` function of PyQt4 and PyQt5 as well as the `QtUiTools.QUiLoader().load` function of PySide/PySide2 are mapped to a convenience function `loadUi`.\n\n```python\nimport sys\nfrom Qt import QtCompat\n\napp = QtWidgets.QApplication(sys.argv)\nui = QtCompat.loadUi(uifile=\"my.ui\")\nui.show()\napp.exec_()\n```\nFor `PyQt` bindings it uses their native implementation, whereas for `PySide` bindings it uses our custom implementation borrowed from the [qtpy](https://github.com/spyder-ide/qtpy) project.\n\n`loadUi` has two arguments as opposed to the multiple that PyQt ships with. See [here](https://github.com/mottosso/Qt.py/pull/81) for details - in a nutshell, those arguments differ between PyQt and PySide in incompatible ways.\nThe second argument is `baseinstance` which allows a ui to be dynamically loaded onto an existing QWidget instance.\n\n```python\nQtCompat.loadUi(uifile=\"my.ui\", baseinstance=QtWidgets.QWidget)\n```\n\n`uifile` is the string path to the ui file to load.\n\nIf `baseinstance` is `None`, the a new instance of the top-level\nwidget will be created. Otherwise, the user interface is created within\nthe given `baseinstance`. In this case `baseinstance` must be an\ninstance of the top-level widget class in the UI file to load, or a\nsubclass thereof. In other words, if you've created a `QMainWindow`\ninterface in the designer, `baseinstance` must be a `QMainWindow`\nor a subclass thereof, too. You cannot load a `QMainWindow` UI file\nwith a plain `QWidget` as `baseinstance`.\n\n`loadUi` returns `baseinstance`, if `baseinstance` is provided.\nOtherwise it will return the newly created instance of the user interface.\n\n<br>\n\n##### sip API v2\n\nIf you're using PyQt4, `sip` attempts to set its API to version 2 for the following:\n- `QString`\n- `QVariant`\n- `QDate`\n- `QDateTime`\n- `QTextStream`\n- `QTime`\n- `QUrl`\n\n<br>\n<br>\n<br>\n\n### Rules\n\nThe PyQt and PySide bindings are similar, but not identical. Where there is ambiguity, there must to be a clear direction on which path to take.\n\n**Governing API**\n\nThe official [Qt 5 documentation](http://doc.qt.io/qt-5/classes.html) is always right. Where the documentation lacks answers, PySide2 is right.\n\nFor example.\n\n```python\n# PyQt5 adheres to PySide2 signals and slots\nPyQt5.Signal = PyQt5.pyqtSignal\nPyQt5.Slot = PyQt5.pyqtSlot\n\n# PySide2 adheres to the official documentation\nPySide2.QtCore.QStringListModel = PySide2.QtGui.QStringListModel\n```\n\n**Caveats**\n\nThere are cases where Qt.py is not handling incompatibility issues. Please see [`CAVEATS.md`](CAVEATS.md) for more information.\n\n<br>\n<br>\n<br>\n\n### Known Problems\n\nSend us a pull-request with known problems here!\n\n- [Maya and incompatible bindings on PYTHONPATH](https://github.com/mottosso/Qt.py/issues/146)\n\n<br>\n<br>\n<br>\n\n### Who's using Qt.py?\n\nSend us a pull-request with your studio here.\n\n- [Atomic Fiction](http://www.atomicfiction.com/)\n- [Bl\u00e4ck](http://www.blackstudios.se/)\n- [Blur Studio](http://www.blur.com)\n- [CGRU](http://cgru.info/)\n- [Colorbleed](http://www.colorbleed.nl/)\n- [Digital Domain](https://www.digitaldomain.com/)\n- [Disney Animation](https://www.disneyanimation.com/)\n- [Dreamworks Animation](https://github.com/dreamworksanimation)\n- [Epic Games](https://www.epicgames.com/)\n- [Fido](http://fido.se/)\n- [Framestore](https://framestore.com)\n- [ftrack](https://www.ftrack.com/)\n- [Futureworks](http://futureworks.in/)\n- [Industrial Brothers](http://industrialbrothers.com/)\n- [Industriromantik](http://www.industriromantik.se/)\n- [Mackevision](http://www.mackevision.com/)\n- [Method Studios](http://www.methodstudios.com/)\n- [Mikros Image](http://www.mikrosimage.com/)\n- [Moonbot Studios](http://moonbotstudios.com/)\n- [MPC](http://www.moving-picture.com)\n- [Overmind Studios](https://www.overmind-studios.de/)\n- [Psyop](http://www.psyop.com/)\n- [Raynault VFX](https://www.raynault.com/)\n- [Rising Sun Pictures](https://rsp.com.au)\n- [Rodeo FX](https://www.rodeofx.com/en/)\n- [Sony Pictures Imageworks](http://www.imageworks.com/)\n- [Spin VFX](http://www.spinvfx.com/)\n- [Weta Digital](https://www.wetafx.co.nz/)\n\nPresented at Siggraph 2016, BOF!\n\n![image](https://cloud.githubusercontent.com/assets/2152766/17621229/c2448db2-6089-11e6-915f-0604e5d8c7ee.png)\n\n<br>\n<br>\n<br>\n\n### Projects using Qt.py\n\nSend us a pull-request with your project here.\n\n- [USD Manager](http://www.usdmanager.org)\n- [Cosmos](http://cosmos.toolsfrom.space/)\n- [maya-capture-gui](https://github.com/BigRoy/maya-capture-gui)\n- [pyblish-lite](https://github.com/pyblish/pyblish-lite)\n- [pyvfx-boilerplate](https://github.com/fredrikaverpil/pyvfx-boilerplate)\n- [riffle](https://gitlab.com/4degrees/riffle)\n- [cmt](https://github.com/chadmv/cmt)\n- [PythonForMayaSamples](https://github.com/dgovil/PythonForMayaSamples)\n- [Kraken](https://github.com/fabric-engine/Kraken)\n- [AFANASY](http://cgru.info/afanasy/afanasy)\n- [Syncplay](https://github.com/Syncplay/syncplay)\n- [BlenderUpdater](https://github.com/overmindstudios/BlenderUpdater)\n- [QtPyConvert](https://github.com/DigitalDomain/QtPyConvert)\n- [Pyper](https://gitlab.com/brunoebe/pyper.git)\n\n<br>\n<br>\n<br>\n\n### Projects similar to Qt.py\n\nComparison matrix.\n\n| Project       | Audience      | Reference binding | License   | PEP8 |Standalone | PyPI   | Co-existence\n|:--------------|:--------------|:------------------|:----------|------|:----------|--------|--------------\n| Qt.py         | Film          | PySide2           | MIT       | X    | X         | X      | X\n| [jupyter][]   | Scientific    | N/A               | N/A       | X    |           |        |\n| [QtPy][]      | Scientific    | N/A               | MIT       |      | X         | X      |\n| [pyqode.qt][] | Scientific    | PyQt5             | MIT       | X    |           | X      |\n| [QtExt][]     | Film          | N/A               | N/A       |      | X         |        |\n| [python_qt_binding][] | Robotics | N/A            | BSD       | X    | X        | X       | X\n\nAlso worth mentioning, [pyqt4topyqt5](https://github.com/rferrazz/pyqt4topyqt5); a good starting point for transitioning to Qt.py.\n\nSend us a pull-request with your project here.\n\n[QtPy]: https://github.com/spyder-ide/qtpy\n[jupyter]: https://github.com/jupyter/qtconsole/blob/master/qtconsole/qt_loaders.py\n[pyqode.qt]: https://github.com/pyQode/pyqode.qt\n[QtExt]: https://bitbucket.org/ftrack/qtext\n[python_qt_binding]: https://github.com/ros-visualization/python_qt_binding\n\n<br>\n<br>\n<br>\n\n### Developer Guide\n\nTests are performed on each aspect of the shim.\n\n- [Functional](tests.py)\n- [Caveats](build_caveats.py)\n- [Examples](examples)\n\nEach of these are run under..\n\n- Python 2.7\n- Python 3.4\n- Python 3.5\n- Python 3.6\n\n..once for each binding or under a specific binding only.\n\nEach test is run within it's own isolated process, so as to allow an `import` to occur independently from other tests. Process isolation is handled via [nosepipe](https://pypi.python.org/pypi/nosepipe).\n\nTests that are written at module level are run four times - once per binding - whereas tests written under a specific if-statement are run only for this particular binding.\n\n```python\nif binding(\"PyQt4\"):\n    def test_something_related_to_pyqt4():\n        pass\n```\n\n**Code convention**\n\nBelow are some of the conventions that used throughout the Qt.py module and tests.\n\n- **Etiquette: PEP8**\n    - All code is written in PEP8. It is recommended you use a linter as you work, flake8 and pylinter are both good options. Anaconda if using Sublime is another good option.\n- **Etiquette: Double quotes**\n    - \" = yes, ' = no.\n- **Etiquette: Napoleon docstrings**\n    - Any docstrings are made in Google Napoleon format. See [Napoleon](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) for details.\n- **Etiquette: Semantic Versioning**\n    - This project follows [semantic versioning](http://semver.org).\n- **Etiquette: Underscore means private**\n    - Anything prefixed with an underscore means that it is internal to Qt.py and not for public consumption.\n\n**Running tests**\n\nDue to the nature of multiple bindings and multiple interpreter support, setting up a development environment in which to properly test your contraptions can be challenging. So here is a guide for how to do just that using **Docker**.\n\nWith Docker setup, here's what you do. Please note this will pull down a ~1 GB image.\n\n```bash\ncd Qt.py\n\n# Run nosetests (Linux/OSX)\ndocker run --rm -v $(pwd):/Qt.py -e PYTHON=2.7 fredrikaverpil/qt.py:2018\ndocker run --rm -v $(pwd):/Qt.py -e PYTHON=3.4 fredrikaverpil/qt.py:2018\ndocker run --rm -v $(pwd):/Qt.py -e PYTHON=3.5 fredrikaverpil/qt.py:2018\ndocker run --rm -v $(pwd):/Qt.py -e PYTHON=3.6 fredrikaverpil/qt.py:2018\n\n# Run nosetests (Windows)\ndocker run --rm -v %CD%:/Qt.py -e PYTHON=2.7 fredrikaverpil/qt.py:2018\ndocker run --rm -v %CD%:/Qt.py -e PYTHON=3.4 fredrikaverpil/qt.py:2018\ndocker run --rm -v %CD%:/Qt.py -e PYTHON=3.5 fredrikaverpil/qt.py:2018\ndocker run --rm -v %CD%:/Qt.py -e PYTHON=3.6 fredrikaverpil/qt.py:2018\n\n# Doctest: test_caveats.test_1_qtgui_qabstractitemmodel_createindex ... ok\n# Doctest: test_caveats.test_2_qtgui_qabstractitemmodel_createindex ... ok\n# Doctest: test_caveats.test_3_qtcore_qitemselection ... ok\n# ...\n#\n# ----------------------------------------------------------------------\n# Ran 21 tests in 7.799s\n#\n# OK\n```\n\nNow both you and Github Actions are operating on the same assumptions which means that when the tests pass on your machine, they pass on Github Actions. And everybody wins!\n\nFor details on the Docker image for testing, see [`DOCKER.md`](DOCKER.md).\n\nSee [`CONTRIBUTING.md`](CONTRIBUTING.md) for more of the good stuff.\n\n**Upload to PyPI**\n\nTo make a new release onto PyPI, you'll need to be mottosso and type this.\n\n```bash\ncd Qt.py\npython .\\setup.py sdist bdist_wheel\npython -m twine upload .\\dist\\*\n```\n\n<br>\n<br>\n<br>\n\n### Qt 6 Transition Guide\n\n| Replace | With | Notes\n|:--------|:-----|:----------------------------\n| `QFont().setWeight(...)` | `QtCompat.QFont.setWeight(font, ...)`\n| `QFont().setWeight(QFont().Bold)` | `QFont().setWeight(QFont.Bold)` | Instance of class doesn't have the enums, apparently\n| `QEvent().Resize` | `QEvent.Resize` | Instance of class doesn't have the enums, seems to apply overall\n| `QtCore.Qt.MidButton`  | `QtCompat.QtCore.Qt.MidButton`\n| `QLabel.setPixmap(str)` | `QLabel.setPixmap(QPixmap())` | Can't take a string anymore (tested in Maya 2025.0)\n| `QModelIndex.child` | `QModel.index` | This one is apparently from Qt 4 and should not have been in Qt.py to begin with\n| | Submit your known issues here! |\n\n##### Removed Members\n\nMany members were removed from Qt.py due to no longer existing in PySide 6.\n\n> If you find where they went, or think some were removed in error, please submit a pull-request!\n\n```json\n\"QtCore\": [\n    \"QAbstractState\",\n    \"QAbstractTransition\",\n    \"QEventTransition\",\n    \"QFinalState\",\n    \"QSignalTransition\",\n    \"QTextCodec\",\n    \"QTextDecoder\",\n    \"QTextEncoder\",\n    \"QtCriticalMsg\",\n    \"QtDebugMsg\",\n    \"QtFatalMsg\",\n    \"QtSystemMsg\",\n    \"QtWarningMsg\",\n    \"qChecksum\",\n    \"QPictureIO\",\n],\n\"QtMultimedia\": [\n    \"QAbstractVideoBuffer\",\n    \"QAbstractVideoSurface\",\n    \"QAudio\",\n    \"QAudioDeviceInfo\",\n    \"QAudioFormat\",\n    \"QAudioInput\",\n    \"QAudioOutput\",\n    \"QVideoFrame\",\n    \"QVideoSurfaceFormat\"\n],\n\"QtNetwork\": [\n    \"QNetworkConfiguration\",\n    \"QNetworkConfigurationManager\",\n    \"QNetworkSession\",\n],\n\"QtOpenGL\": [\n    \"QGL\",\n    \"QGLContext\",\n    \"QGLFormat\",\n    \"QGLWidget\"\n],\n\"QtSql\": [\n    \"QSql\",\n    \"QSqlDatabase\",\n    \"QSqlDriver\",\n    \"QSqlDriverCreatorBase\",\n    \"QSqlError\",\n    \"QSqlField\",\n    \"QSqlIndex\",\n    \"QSqlQuery\",\n    \"QSqlQueryModel\",\n    \"QSqlRecord\",\n    \"QSqlRelation\",\n    \"QSqlRelationalDelegate\",\n    \"QSqlRelationalTableModel\",\n    \"QSqlResult\",\n    \"QSqlTableModel\"\n],\n\"QtSvg\": [\n    \"QSvgGenerator\",\n    \"QSvgRenderer\",\n],\n\"QtWidgets\": [\n    \"QActionGroup\",\n    \"QDesktopWidget\",\n    \"QDirModel\",\n    \"QKeyEventTransition\",\n    \"QMouseEventTransition\",\n    \"QUndoCommand\",\n    \"QUndoGroup\",\n    \"QUndoStack\",\n],\n\"QtX11Extras\": [\n    \"QX11Info\"\n],\n\"QtXml\": [\n    \"QXmlAttributes\",\n    \"QXmlContentHandler\",\n    \"QXmlDTDHandler\",\n    \"QXmlDeclHandler\",\n    \"QXmlDefaultHandler\",\n    \"QXmlEntityResolver\",\n    \"QXmlErrorHandler\",\n    \"QXmlInputSource\",\n    \"QXmlLexicalHandler\",\n    \"QXmlLocator\",\n    \"QXmlNamespaceSupport\",\n    \"QXmlParseException\",\n    \"QXmlReader\",\n    \"QXmlSimpleReader\"\n],\n\"QtXmlPatterns\": [\n    \"QAbstractMessageHandler\",\n    \"QAbstractUriResolver\",\n    \"QAbstractXmlNodeModel\",\n    \"QAbstractXmlReceiver\",\n    \"QSourceLocation\",\n    \"QXmlFormatter\",\n    \"QXmlItem\",\n    \"QXmlName\",\n    \"QXmlNamePool\",\n    \"QXmlNodeModelIndex\",\n    \"QXmlQuery\",\n    \"QXmlResultItems\",\n    \"QXmlSchema\",\n    \"QXmlSchemaValidator\",\n    \"QXmlSerializer\"\n]\n```\n\n##### Static Members Missing from Instances\n\nAn overall change is that instances of classes, like `QFont()` no longer provides access to static members, such as `QFont.Bold`. So things like:\n\n```py\nfont = QFont()\nfont.setWeight(font.Bold)\n```\n\nMust be replaced with:\n\n```py\nfont = QFont()\nfont.setWeight(QFont.Bold)\n```\n\nOr:\n\n```py\nfont.setWeight(type(font).Bold)\n```\n\nTedious and seemingly unnecessary.. But there you have it!\n\n##### Notes\n\nQt.py 1.4.0, released in May 2024, added support for Qt 6 whilst preserving compatibility with Qt 4 and 5. That means that in most cases, code you've already written for Qt 4 or 5 will now continue to work with Qt 6, such as Maya 2025.\n\nHowever, some changes between 5 and 6 require up-front work by you the developer to make your codebase run on Qt 6 whilst continuing to run on Qt 4 and 5.\n\nThe above is what we know, please do submit issues and pull-request with what else you find!\n\n- https://github.com/mottosso/Qt.py/issues/new\n\n**See also**\n\nThe official PySide2 to PySide6 transition guide, which is especially helpful since Qt.py is modeled after PySide2.\n\n- https://doc.qt.io/qtforpython-6/gettingstarted/porting_from2.html\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python 2 & 3 compatibility wrapper around all Qt bindings - PySide, PySide2, PyQt4 and PyQt5.",
    "version": "1.4.1",
    "project_urls": {
        "Homepage": "https://github.com/mottosso/Qt"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0aa6f7cc5bea08d7891f9deaaaa9328e39ded9119db23bc4ae2a70c2f5a477ba",
                "md5": "9e6ba828ad87e9a661de30e784fd937b",
                "sha256": "751eabac526da6836df9234797c85b3ea0517b1337a316a313cff71d4e05964c"
            },
            "downloads": -1,
            "filename": "Qt.py-1.4.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9e6ba828ad87e9a661de30e784fd937b",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 35893,
            "upload_time": "2024-05-15T06:30:04",
            "upload_time_iso_8601": "2024-05-15T06:30:04.718711Z",
            "url": "https://files.pythonhosted.org/packages/0a/a6/f7cc5bea08d7891f9deaaaa9328e39ded9119db23bc4ae2a70c2f5a477ba/Qt.py-1.4.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cc972f9c8aaa3380624383ddf1dd492ca691d02900cbaa31cfd18ad0cbc85daf",
                "md5": "87ce20f959daa90eff00c57877996c05",
                "sha256": "c04ac2cedb5aeb710630f5443c032819aab4f6638aaa0105a9aacde66a337cf4"
            },
            "downloads": -1,
            "filename": "Qt.py-1.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "87ce20f959daa90eff00c57877996c05",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 49400,
            "upload_time": "2024-05-15T06:30:07",
            "upload_time_iso_8601": "2024-05-15T06:30:07.063590Z",
            "url": "https://files.pythonhosted.org/packages/cc/97/2f9c8aaa3380624383ddf1dd492ca691d02900cbaa31cfd18ad0cbc85daf/Qt.py-1.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-15 06:30:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mottosso",
    "github_project": "Qt",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "qt.py"
}
        
Elapsed time: 0.24606s