# Migrating PyQt5 Code to PySide6

Starting from version 9.2, IDA has moved from **Qt5** to **Qt6**. For more details, see the [IDA 9.2 Release Notes](/release-notes/9_2.md#qt6)

| IDA Version | Qt Version | Python Qt Bindings                                                             |
| ----------- | ---------- | ------------------------------------------------------------------------------ |
| ≤ 9.1       | Qt5        | [PyQt5](https://www.riverbankcomputing.com/static/Docs/PyQt5/)                 |
| 9.2         | Qt6        | [PySide6](https://doc.qt.io/qtforpython-6/gettingstarted.html#getting-started) |

## PyQt5 vs PySide6

* Different module names; `from PyQt5 import QtWidgets` will no longer work in PySide6.
* Differences in Qt libraries **themselves**

As a result, some existing user scripts may require adjustments. **That's why we prepare** [**PyQt5 shims**](#pyqt5-shims) **to ease your transition**.

## PyQt5 Shims

We have introduced a compatibility layer, called “PyQt5 shims, to support a **smooth transition** for existing scripts relying on PyQt5.

These shims:

* provide `PyQt5.*` Python modules
* behind the scenes, re-route calls to PySide6 (Qt6) and perform additional handling to ensure compatibility

The goal is to let your existing PyQt5-based code continue running as it should.

{% hint style="info" %}
Although these shims aim to ease the transition, please note that they have [limitations](#known-limitations). We recommend [porting](#additional-resources) existing code to PySide6, or using an abstraction layer such as [QtPy](https://github.com/spyder-ide/qtpy).
{% endhint %}

### Enabling/Disabling the Shims

On the **first attempt** to import `PyQt5` (either directly or through a plugin), IDA will display a **popup dialog** asking whether to enable/disable PyQt5 shims.

![Shims confirmation dialog](/files/uPPC0TSJXNo5w87posnF)

No manual editing is required - simply respond to the prompt.

Your choice will be saved in the configuration file:

* **Windows**: `%APPDATA%\Hex-Rays\IDA Pro\cfg\idapython.cfg`
* **Linux/macOS**: `~/.idapro/cfg/idapython.cfg`

The paths depend on `IDAUSR`.

After making a choice, IDA will:

* Print a message in the [Output Window](https://github.com/HexRaysSA/ida-docs/blob/9.3/ida-actions/outputwindow.md)
* Inform you of the updated configuration path
* Remember your choice and not prompt you again

### Changing the Shims Preferences

You can edit `cfg/idapython.cfg` at any time to change the configuration.

To **enable** PyQt5 shims:

```
#if __IDAVER__ >= 920
IDAPYTHON_USE_PYQT5_SHIM = 1
#endif
```

To **disable** PyQt5 shims:

```
#if __IDAVER__ >= 920
IDAPYTHON_USE_PYQT5_SHIM = 0
#endif
```

{% hint style="info" %}
The `#if __IDAVER__ >= 920` directive ensures that the configuration is ignored by older versions of IDA. However, this is unnecessary if you update `idapython.cfg` directly within the IDA installation directory.
{% endhint %}

## Additional Resources

* [Qt5 to Qt6 porting guide - Qt](https://doc.qt.io/qt-6/portingguide.html)
* [Migrate PyQt5 to PySide2 - GeeksForGeeks](https://www.geeksforgeeks.org/python/migrate-pyqt5-app-to-pyside2/)
* [Porting from PySide2 to PySide6 - Qt for Python](https://doc.qt.io/qtforpython-6/faq/porting_from2.html)
* [QtPy - Github](https://github.com/spyder-ide/qtpy)

## Known Limitations

* QRegExp:
  * `PyQt5.QtCore.QRegExp` is deprecated in Qt6
  * There has already been a replacement - `PyQt5.QtCore.QRegularExpression`
  * `QRegExp` and `QRegularExpression` are incompatible. They differ in methods and the pattern syntax. See [Qt porting guide](https://doc.qt.io/qt-6/qregexp.html#porting-to-qregularexpression) for more details.
* QFontDatabase:
  * `PyQt5.QtGui.QFontDatabase` and `PySide6.QtGui.QFontDatabase` differ in the declaration of static methods and in derived methods available on `QFontDatabase` instances
  * It is marked as deprecated in Qt6


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hex-rays.com/developer/publishing-plugins/how-tos/migrating-pyqt5-code-to-pyside6.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
