Maya has moved from Qt5 and PySide2 to Qt6 and PySide6.
Information about porting C++ source code from Qt5 to Qt6 is available at https://doc.qt.io/qt-6/portingguide.html.
Information about porting Python source code from Qt5 to Qt6 is available at https://doc.qt.io/qtforpython-6/gettingstarted/porting_from2.html.
The following changes are most relevant to users of the Maya devkit:
Qt <platform>Extras
has been moved to QNativeInterface
.mayaSharedGLWidget
property has been replaced by mayaSharedQOpenGLContext
.MQtUtil::resourceGLContext()
now returns QOpenGLContext
.QObjects
is no longer required.QtRegEx
has been replaced with QRegularExpression
.QAction
, QActionGroup
, QShortcut
, and QFileSystemModel
have been moved to QtGui
.QT_DISABLE_DEPRECATED_UP_TO = 0x050F00
preprocessor directive helps to identify deprecated Qt APIs.We encourage users who build Qt plug-ins to provide feedback about their experience with Qt6 on the special Qt6 section of the forums.
Check your high dpi logic, and verify that your plug-ins look correct on both high dpi displays and on mixed scaling environments.
Qt <platform>Extras
has been moved to QNativeInterface
See the Qt documentation on native interfaces for more details
PySide6 Qt enums have changed from being Shiboken enums to true Python enums. While these are compatible in general, there are some differences:
For information on migrating from the old to the new enums, see Doing a Smooth Transition from the Old Enums in the Qt documentation.
When using PySide scripts with both Qt6 and Qt5 builds of Maya, a try...except
block can be used to import the appropriate version of Qt.
try:
from PySide6.QtCore import QObject, Qt
except ImportError:
from PySide2.QtCore import QObject, Qt
Tools such as pyside2-uic
and pyside2-rcc
have changed name to pyside6-uic
and pyside6-rcc
.
The mayaSharedGLWidget
property has been removed and replaced with the mayaSharedQOpenGLContext
property.
As with mayaSharedGLWidget
, the purpose of mayaSharedQOpenGLContext
is to grant access to the shared GL context.
mayaSharedGLWidget
was a QWidget
pointer to a QGLWidget
with a shared context. The context was obtained from the widget.
mayaSharedQOpenGLContext
is a QObject
pointer to the Maya viewport's QOpenGLContext
. This means that the context is obtained directly from mayaSharedQOpenGLContext
rather than through the GL widget.
For example, in Python:
from PySide6.QtWidgets import QApplication
context = QApplication.instance().property("mayaSharedQOpenGLContext")
# context is type <class 'PySide6.QtGui.QOpenGLContext'>
And in C++:
#include <QApplication>
#include <QVariant>
#include <QOpenGLContext>
[...]
QVariant ctxVariant = QApplication::instance()->property("mayaSharedQOpenGLContext");
QOpenGLContext *context = ctxVariant.value<QOpenGLContext*>();
Because QGLContext
is deprecated in Qt6, MQtUtil::resourceGLContext()
now returns QOpenGLContext
.
QGLContext *MQtUtil::resourceGLContext()
QObjects
is no longer requiredExplicit wrapping of QObjects
is no longer required. A change in QVariant
means that the most specific wrapper will always be used automatically.
For example, in this case:
app = QApplication.instance()
sharedGLContext = app.property("mayaSharedQOpenGLContext")
The returned property is a QOpenGLContext
. It does not need to be manually cast or wrapped.
QtRegEx
has been replaced with QRegularExpression
. QAction
, QActionGroup
, QShortcut
, and QFileSystemModel
have been moved to QtGui
. QT_DISABLE_DEPRECATED_UP_TO = 0x050F00
preprocessor directiveThe QT_DISABLE_DEPRECATED_UP_TO = 0x050F00
preprocessor directive prevents Qt5 code that uses deprecated Qt APIs that are not in Qt6 from compiling. This directive should be used even when using Qt5. See the Qt porting guide's section on disabling the use of deprecated C++ API for more information.