将Maya模型编辑器嵌入到PyQt UI中



将modelEditor添加到QFrame时遇到问题如果可以的话,请帮帮我。谢谢

=>这是我在Qt Designer中创建的UIhttp://farm3.staticflickr.com/2944/15230904617_a2b8608d2d_b.jpg

这里是加载UI&添加功能

import maya.OpenMayaUI as mui
import sip
from PyQt4 import QtGui, QtCore, uic
import maya.cmds as mc
import maya.mel as mm
def getMayaWindow():
    # ‘Get the maya main window as a QMainWindow instance’
    ptr = mui.MQtUtil.mainWindow()
    return sip.wrapinstance(long(ptr), QtCore.QObject)
def toQtObject(mayaName):
    ”’
    Given the name of a Maya UI element of any type,
    return the corresponding QWidget or QAction.
    If the object does not exist, returns None
    ”’
    ptr = apiUI.MQtUtil.findControl(mayaName)
    if ptr is None:
        ptr = apiUI.MQtUtil.findLayout(mayaName)
        if ptr is None:
            ptr = apiUI.MQtUtil.findMenuItem(mayaName)
            if ptr is not None:
                return sip.wrapinstance(long(ptr), QtCore.QObject)
uiFile = (‘D:/modEditorTestUI.ui’)
form_class, base_class = uic.loadUiType(uiFile)
class myUIClass(form_class, base_class):
    def __init__(self, parent=getMayaWindow()):
        super(myUIClass, self).__init__(parent)
        self.setupUi( self )
        self.snapView = mc.modelEditor(displayAppearance=’smoothShaded’, displayTextures=True, wos=False, camera=’persp’)
        qtObj = toQtObject(self.snapView)
        print (‘qtObj: ‘ + str(qtObj))
        #methods
        self.connectSignals()
    def connectSignals(self):
        “”"Connect all the UI signals”"”
        print “Connect signals”
def runUI():
    global app
    global win
    app=QtGui.qApp
    win = myUIClass()
    win.show()
runUI()

从您提供的代码片段来看,由于最后一个if和return语句的缩进,toQtObject方法似乎不会返回任何有用的内容。这是固定的:

def toQtObject(mayaName):
    """
    Given the name of a Maya UI element of any type,
    return the corresponding QWidget or QAction.
    If the object does not exist, returns None
    """
    ptr = apiUI.MQtUtil.findControl(mayaName)
    if ptr is None:
        ptr = apiUI.MQtUtil.findLayout(mayaName)
        if ptr is None:
            ptr = apiUI.MQtUtil.findMenuItem(mayaName)
    if ptr is not None:
        return sip.wrapinstance(long(ptr), QtCore.QObject)

最新更新