[MAYA] PySide and Maya UI component

Hey Guys,

Is there a way to embed a Maya UI component to a PySide window? I would like to add a Maya UI cmds.attControlGrp() to a PySide window it would save me lots of code and time if I could get that to work. Any ideas on how to do that?

Cheers,

Will

Use MQtUtil module. Look here for details


import maya.OpenMayaUI as omui

# foo window
pmc.window()
pmc.columnLayout()
atcrl = pmc.attrControlGrp(attribute='defaultResolution.width')
pmc.showWindow()

# get QWidget
qwidget = omui.MQtUtil.findControl(atcrl)

[QUOTE=Styler;29909]Use MQtUtil module. Look here for details


import maya.OpenMayaUI as omui

# foo window
pmc.window()
pmc.columnLayout()
atcrl = pmc.attrControlGrp(attribute='defaultResolution.width')
pmc.showWindow()

# get QWidget
qwidget = omui.MQtUtil.findControl(atcrl)

[/QUOTE]

Thanks for the answer. The qwidget type is SwigPyObject, is there anyway to get it to return it as a QWidget so that it can be added to a PySide layout?
Sori, I might be in way over my head for doing this, maybe its not as easy as I thought it would be :slight_smile:

[QUOTE=Tigerwilly;29912]Thanks for the answer. The qwidget type is SwigPyObject, is there anyway to get it to return it as a QWidget so that it can be added to a PySide layout?
Sori, I might be in way over my head for doing this, maybe its not as easy as I thought it would be :)[/QUOTE]

Ok got it working like this,

from shiboken import wrapInstance
ptr = omui.MQtUtil.findControl(pmc.attrControlGrp(attribute=“joint1.rotateOrder”, label=“testJoint”))
qwidget = wrapInstance(long(ptr), QtGui.QWidget)
self.horizontalLayoutTest.addWidget(qwidget)

Cheers!

Here is a nice function for doing the conversion,

def mayaToQtObject(inMayaUI):
    ptr = omui.MQtUtil.findControl(inMayaUI)
    if ptr is None:
        ptr = omui.MQtUtil.findLayout(inMayaUI)
    if ptr is None:
        ptr = omui.MQtUtil.findMenuItem(inMayaUI)
    if ptr is not None:
        return wrapInstance(long(ptr), QtGui.QWidget)