Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Add initial Methods, helpers and QtPy namespace specifics section to the README #357

Merged
merged 3 commits into from
Jul 25, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,44 @@ default unless you set the `QT_API` environment variable.
* `pyside6` (to use PySide6).


### Methods, helpers and QtPy namespace specifics

As part of providing compatibility for the different Python Qt bindings available, QtPy does some modules mapping and exposes a `compat` module. Bellow you can check some elements to take into account when using QtPy.

#### Module aliases and constants
dalthviz marked this conversation as resolved.
Show resolved Hide resolved

* `QtCore.pyqtSignal`, `QtCore.pyqtSlot` and `QtCore.pyqtProperty` (available on PyQt5/6) are replaced by `QtCore.Signal`, `QtCore.Slot` and `QtCore.Property` following the Qt5 module layout.
dalthviz marked this conversation as resolved.
Show resolved Hide resolved

* The Qt version being used can be checked with `QtCore.__version__` (instead of `QtCore.QT_VERSION_STR`) as well as from `qtpy.QT_VERSION`.

* For PyQt6 enums, unscoped enum access was added by
promoting the enums of the `QtCore`, `QtGui`, `QtTest` and `QtWidgets` modules.
dalthviz marked this conversation as resolved.
Show resolved Hide resolved

* Compatibility is added between the `QtGui` and `QtOpenGL` modules for `QOpenGL*` classes.
dalthviz marked this conversation as resolved.
Show resolved Hide resolved

* To check the current PySide2/6 binding version you can use `qtpy.PYSIDE_VERSION`. If PySide is not being used as the binding the value returned will be `None`.

* To check the current PyQt5/6 binding version you can use `qtpy.PYQT_VERSION`. If PyQt is not being used as the binding the value returned will be `None`.
dalthviz marked this conversation as resolved.
Show resolved Hide resolved

* To check the current selected binding you can use `qtpy.API_NAME`
dalthviz marked this conversation as resolved.
Show resolved Hide resolved

* There are boolean values to check if Qt5/6, PyQt5/6 or PySide2/6 are being used: `qtpy.Qt5`, `qtpy.Qt6`, `qtpy.PYQT5`, `qtpy.PYQT6`, `qtpy.PYSIDE2` and `qtpy.PYSIDE6`. `True` if currently being used, `False` otherwise.

#### Compat module

In the `qtpy.compat` module you can find wrappers for `QFileDialog` static methods and sip/shiboken functions as:
dalthviz marked this conversation as resolved.
Show resolved Hide resolved

* `QFileDialog.getExistingDirectory` wrapped with `qtpy.compat.getexistingdirectory`

* `QFileDialog.getOpenFileName` wrapped with `qtpy.compat.getopenfilename`

* `QFileDialog.getOpenFileNames` wrapped with `qtpy.compat.getopenfilenames`

* `QFileDialog.getSaveFileName` wrapped with `qtpy.compat.getsavefilename`

* `sip.isdeleted` and `shiboken.isValid` wrapped with `qtpy.compat.isalive`


### Installation

```bash
Expand Down