Hello guys. I’ve got following problem.
Here is a little code that creates a simple Maya UI and then inserts a QTableView in it.
And its working very well and everything is fine.
import maya.cmds as m
import maya.OpenMayaUI as omui
import sip
from PyQt4 import QtCore
from PyQt4 import QtGui
UI_WIN_NAME = 'test_pyqt_embedding_win'
class TestUI(object):
def __init__(self):
if m.window(UI_WIN_NAME, exists=True):
m.deleteUI(UI_WIN_NAME, window=True)
self.window = m.window(UI_WIN_NAME)
self.uiLAY_mainRow = m.columnLayout(adjustableColumn=True)
self.uiLAY_attachFrame = m.frameLayout(marginHeight=2, marginWidth=2, borderVisible=True, labelVisible=True)
self.uiBTN_test = m.button()
self.uiQTLAY_attachFrame = sip.wrapinstance(long(omui.MQtUtil.findLayout(self.uiLAY_attachFrame)), QtCore.QObject)
self.uiQTLAY_attachLayout = self.uiQTLAY_attachFrame.children()[-1].layout()
self.uiQTTBL_test = QtGui.QTableView()
self.uiQTLAY_attachLayout.addWidget(self.uiQTTBL_test)
m.showWindow(self.window)
def run():
TestUI()
But if i try to do this stuff in PySide (only 4 lines has been changed) it fails with an error “# Error: RuntimeError: file … estEmbeddingPySide.py line 25: Internal C++ object (PySide.QtGui.QVBoxLayout) already deleted. #”
import maya.cmds as m
import maya.OpenMayaUI as omui
import shiboken
from PySide import QtCore
from PySide import QtGui
UI_WIN_NAME = 'test_pyside_embedding_win'
class TestUI(object):
def __init__(self):
if m.window(UI_WIN_NAME, exists=True):
m.deleteUI(UI_WIN_NAME, window=True)
self.window = m.window(UI_WIN_NAME)
self.uiLAY_mainRow = m.columnLayout(adjustableColumn=True)
self.uiLAY_attachFrame = m.frameLayout(marginHeight=2, marginWidth=2, borderVisible=True, labelVisible=True)
self.uiBTN_test = m.button()
self.uiQTLAY_attachFrame = shiboken.wrapInstance(long(omui.MQtUtil.findLayout(self.uiLAY_attachFrame)), QtCore.QObject)
self.uiQTLAY_attachLayout = self.uiQTLAY_attachFrame.children()[-1].layout()
self.uiQTTBL_test = QtGui.QTableView()
self.uiQTLAY_attachLayout.addWidget(self.uiQTTBL_test)
m.showWindow(self.window)
def run():
TestUI()
Any idea how can i fix it? Or may be i’m doing something wrong?