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 accessible from 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 access 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.
Do not create new QApplication
objects. An exception will be thrown if you do.
Once you have a pointer 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 PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication, QPushButton
app = QApplication.instance()
button = QPushButton("About Qt")
button.clicked.connect(app.aboutQt)
button.setAttribute(Qt.WA_DeleteOnClose)
button.show()
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.