在其 Python 编辑器控制台中运行此代码后,我试图在父 Maya 或 Motionbuilder 程序的顶部保留一个对话框窗口,但我似乎无法理解。现在,窗口将停留在一切之上,这不是我想要的。我只希望它位于父 3D 程序窗口的顶部。
这是代码:
from PySide import QtCore, QtGui
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(400, 300)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
class Dialog(QtGui.QDialog, Ui_Dialog):
def __init__(self, parent=None):
super(Dialog, self).__init__(parent)
self.setupUi(self)
if __name__ in ('__main__', '__builtin__'):
app = QtGui.QApplication.instance()
print(app.topLevelWidgets())
if app is None:
app = QtGui.QApplication([])
w = Dialog(app.topLevelWidgets()[0])
w.show()
app.exec_()
打印输出(app.topLevelWidgets()):
[<PySide.QtGui.QMenu object at 0x0000000032F97348>, <PySide.QtGui.QWidget object at 0x0000000032F97388>, <PySide.QtGui.QWidget object at 0x0000000032F973C8>, <PySide.QtGui.QMenu object at 0x0000000032F97408>, <PySide.QtGui.QWidget object at 0x0000000032F97448>, <PySide.QtGui.QMenu object at 0x0000000032F97488>, <PySide.QtGui.QWidget object at 0x0000000032F974C8>, <PySide.QtGui.QWidget object at 0x0000000032F97508>, <PySide.QtGui.QWidget object at 0x0000000032F97548>, <PySide.QtGui.QMenu object at 0x0000000032F97588>, <PySide.QtGui.QWidget object at 0x0000000032F975C8>, <PySide.QtGui.QMenu object at 0x0000000032F97608>, <PySide.QtGui.QWidget object at 0x0000000032F97648>, <PySide.QtGui.QWidget object at 0x0000000032F97688>, <PySide.QtGui.QWidget object at 0x0000000032F976C8>, <PySide.QtGui.QWidget object at 0x0000000032F97708>, <PySide.QtGui.QWidget object at 0x0000000032F97748>, <PySide.QtGui.QMenu object at 0x0000000032F97788>, <PySide.QtGui.QMenu object at 0x0000000032F977C8>, <PySide.QtGui.QWidget object at 0x0000000032F97808>, <PySide.QtGui.QWidget object at 0x0000000032F97848>, <PySide.QtGui.QWidget object at 0x0000000032F97888>, <PySide.QtGui.QMainWindow object at 0x0000000032F92EC8>, <PySide.QtGui.QWidget object at 0x0000000032F978C8>, <PySide.QtGui.QMenu object at 0x0000000032F97908>, <PySide.QtGui.QMenu object at 0x0000000032F97948>, <PySide.QtGui.QMenu object at 0x0000000032F97988>, <PySide.QtGui.QMenu object at 0x0000000032F979C8>, <PySide.QtGui.QWidget object at 0x0000000032F97A08>, <PySide.QtGui.QMenu object at 0x0000000032F97A48>, <PySide.QtGui.QMenu object at 0x0000000032F97A88>, <PySide.QtGui.QMenu object at 0x0000000032F97AC8>, <PySide.QtGui.QWidget object at 0x0000000032F97B08>, <Dialog object at 0x0000000032F92F88>, <PySide.QtGui.QWidget object at 0x0000000032F97B48>, <PySide.QtGui.QMenu object at 0x0000000032F97B88>, <PySide.QtGui.QMenu object at 0x0000000032F97BC8>, <PySide.QtGui.QMenu object at 0x0000000032F97C08>, <PySide.QtGui.QWidget object at 0x0000000032F97C48>, <PySide.QtGui.QWidget object at 0x0000000032F97C88>, <PySide.QtGui.QMenu object at 0x0000000032F97CC8>]