Hello everybody !
I need to put a PyQt (for example a QListWidget) widget in UI which is created using MEL (i mean my tool UI… not some Maya main window place)
There is a frameLayout which is resizing with the main window, but the problem is that my QListWidget in that frameLayout does not.
It has a fixed size. Looks like my QHBoxLayout setup doesn’t work but i dont know why.
Here is the code.
import sip
from PyQt4 import QtGui, QtCore
import maya.OpenMayaUI as omui
import maya.cmds as m
UI_WIN_NAME = 'WidgetInMayaUI_win'
UI_WIN_TITLE = 'WidgetInMayaUI window'
class WidgetInMayaUI():
def __init__(self) :
self.ui_createUI()
def ui_createUI(self):
if m.window(UI_WIN_NAME, exists = True) : m.deleteUI(UI_WIN_NAME, window = True)
self.window = m.window( UI_WIN_NAME, title = UI_WIN_TITLE, maximizeButton = False,)
self.ui_LAY_mainForm = m.formLayout()
self.attachLayout = m.frameLayout(labelVisible = False)
m.setParent(self.ui_LAY_mainForm)
self.ui_LAY_toolbar = m.columnLayout()
m.symbolCheckBox(image = 'sortName', height = 35, width = 35)
m.symbolCheckBox(image = 'sortName', height = 35, width = 35)
m.symbolCheckBox(image = 'sortName', height = 35, width = 35)
m.formLayout(self.ui_LAY_mainForm, e = True, attachForm = (self.attachLayout, 'top', 2))
m.formLayout(self.ui_LAY_mainForm, e = True, attachControl = (self.attachLayout, 'right', 2, self.ui_LAY_toolbar))
m.formLayout(self.ui_LAY_mainForm, e = True, attachForm = (self.attachLayout, 'bottom', 2))
m.formLayout(self.ui_LAY_mainForm, e = True, attachForm = (self.attachLayout, 'left', 2))
m.formLayout(self.ui_LAY_mainForm, e = True, attachForm = (self.ui_LAY_toolbar, 'top', 2))
m.formLayout(self.ui_LAY_mainForm, e = True, attachForm = (self.ui_LAY_toolbar, 'right', 2))
m.formLayout(self.ui_LAY_mainForm, e = True, attachForm = (self.ui_LAY_toolbar, 'bottom', 2))
m.formLayout(self.ui_LAY_mainForm, e = True, attachNone = (self.ui_LAY_toolbar, 'left'))
self.attachLayoutQ = sip.wrapinstance(long(omui.MQtUtil.findLayout(self.attachLayout)), QtCore.QObject)
self.QtLayout = QtGui.QHBoxLayout()
self.attachLayoutQ.setLayout(self.QtLayout)
self.list = QtGui.QListWidget()
self.list.addItem('aaa'); self.list.addItem('bbb'); self.list.addItem('ccc')
self.QtLayout.addWidget(self.list)
self.list.setParent(self.attachLayoutQ)
m.showWindow(self.window)
def run():
WidgetInMayaUI()
So how can i embed a QWidget in this UI and make it resize with frameLayout?