This method is helpful for parenting a PySide or PyQt dialog to the main window. Parenting to the main window keeps the dialog alive for the lifetime of the window so that the dialog is not destroyed prematurely by Python. Parenting also causes the dialog to inherit the Houdini style sheet set on the main window.
Here is an example of parenting a dialog to the main window:
from hutil.Qt import QtCore dialog = MyDialog() dialog.setParent(hou.qt.mainWindow(), QtCore.Qt.Window) dialog.show()
Note that a parented dialog will be alive even when it is closed. If you want to destroy the dialog when it is closed then you need to implement the closeEvent method handler and unparent the dialog. For example:
import Qt.QtWidgets as QtWidgets class MyDialog(QtWidgets.QFrame): ... def closeEvent(self, event): self.setParent(None)