I’ve been trying to parent a window to another window and have found that whenever I try to parent them the child window stops showing. To simplify the problem I tried to parent the window to the main maya window but had the same result.
If we execute the following code no window will appear and both prints will show the same directory. Therefore the widget’s parent is the main maya application. If you remove “widget” from line 12 the window will show but it will no longer be parented to the main maya window.
My real intention is create secondary windows that will not hide under the main maya window. Right now all my windows come out as a separate main window and will hide whenever we click the main window. I tried setting self.setWindowFlags(core.Qt.WindowStaysOnTopHint) but that stays on top of every window on the computer which is not really the desired result. Any help would be greatly appreciated!
from maya import cmds from maya import OpenMayaUI as omui from PySide2.QtCore import * from PySide2.QtGui import * from PySide2 import QtWidgets as wdg from shiboken2 import wrapInstance win = None def init(): global win ptr = omui.MQtUtil.mainWindow() widget = wrapInstance(long(ptr), wdg.QWidget) win = bikes_LightingTool(widget) print widget class bikes_LightingTool(wdg.QWidget): def __init__(self, parent=None): super(bikes_LightingTool, self).__init__(parent) self.parent_widget = parent lay = wdg.QHBoxLayout(self) lay.addWidget(wdg.QPushButton()) self.show() print self.parent() init()