Writing Qt plug-ins

You can use the Qt cross-platform toolkit to customize Maya's user interface.

Maya has its own application object that is passed to a Qt plug-in. Because of this, you do not have to create your own QApplication object.

You can use QApplication.instance() or the qApp macro to get a reference to the Maya QApplication object. You can call QApplication.instance() and qApp more than once to get more than one reference to the Maya QApplication object.

Important: Do not create new QApplication objects.

Once you have your reference to the Maya QApplication object, you can then use the standard Qt calls to to create your plug-in application. See the Qt documentation for more information.

from PySide2.QtCore import Qt
from PySide2.QtWidgets import QApplication, QPushButton
app = QApplication.instance()
button = QPushButton("About Qt")
button.clicked.connect(app.aboutQt)
button.setAttribute(Qt.WA_DeleteOnClose)
button.show()

Note: If you are using layouts with Maya and Qt, you will need to understand the details of how Maya and Qt layouts interact. See the documentation for MQUtil in the C++ Reference for detailed information about how Maya and Qt layouts work together.