Pyqt中的Maya Outliner不收费 [英] Maya Outliner in Pyqt doesn't charge
问题描述
好吧,我正在尝试使用Pyqt4和python在maya中使用大纲视图,我的大纲视图与另外两个面板在Qsplitter中,似乎代码还可以,但是当我运行代码时,有时出现大纲视图,有时却没有不会出现
Well I'm trying to use a outliner in maya with Pyqt4 and python, My outliner is in a Qsplitter with other two panels, it seems the code is ok, but when I run the code sometimes the Outliner appears, sometimes doesn't appear
这是我创建大纲视图的代码:
this is the code where I create the Outliner:
self.outliner = QWidget()
self.outliner.setObjectName("outliner")
self.outLayout = QGridLayout()
self.outLayout.setContentsMargins(0, 0, 0, 0)
self.outLayout.setObjectName("outLayout")
self.outliner.setLayout(self.outLayout)
outL = cmds.outlinerPanel(mbv=False, p="outLayout")
cmds.control(out, edit=True, visible=True, parent="outLayout")
这是我的显示方式:
self.splitter1 = QSplitter()
self.splitter1.addWidget(self.list)
self.splitter1.addWidget(self.outliner)
我需要修改使其每次都能正常工作
What I need to modify to make it work every time
我升级了代码,删除了前行,但仍然无法按我需要的方式工作
I Upgraded my code, deleting inecesaring lines, but still doesn't work the way i need
推荐答案
这是我完成的操作:
第一部分相同
self.outliner = QWidget()
self.outliner.setObjectName("outliner")
self.outLayout = QGridLayout()
self.outLayout.setContentsMargins(0, 0, 0, 0)
self.outLayout.setObjectName("outLayout")
self.outliner.setLayout(self.outLayout)
然后我将Pyqt翻译"为maya,以便能够为布局分配任何额外的代码
then I "translate" Pyqt to maya to be able to assign the layout with any extra code
panel = mui.MQtUtil.fullName(long(sip.unwrapinstance(self.outLayout)))
cmds.setParent(panel)
if cmds.modelPanel("outL", exists=True):
cmds.deleteUI("outL")
outL = cmds.outlinerPanel(mbv=False)
cmds.control(outL, edit=True, visible=True, p=panel)
ptr = mui.MQtUtil.findControl(outL)
将Maya小部件转换为QWidget
Transform a Maya widget to a QWidget
self.outPanel = sip.wrapinstance(long(ptr), QObject)
最后将小部件添加到我的布局中
And Finally add the Widget to my Layout
self.outLayout.addWidget(self.outPanel)
这篇关于Pyqt中的Maya Outliner不收费的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!