Hello all! I’m playing around in Maya with PyQt and with all the helpful posts I’ve been able to make great progress. I’ve run into an issue dealing with QWidgets not resizing properly. The following code is a small example, though it’s a little contrived. Basically the QScrollArea remains at a fixed size. I’ve read much of the documentation on QSizePolicy and attempted to set the policy for both the scroll area and the formlayout to which it’s parented, but it did not work. Also, I understand that in Qt, a layout is NOT a widget, however in Maya the underlying obect IS a QWidget. This is probably adding to my confusion.
I’d like the scroll area to change accordingly when the window is re-sized.
So what am i doing wrong?
from PyQt4 import QtGui, QtCore
import maya.OpenMayaUI as mui
import sip
import maya.cmds as cmds
import os
def getControl(controlName):
ptr = mui.MQtUtil.findControl(controlName)
return sip.wrapinstance(long(ptr), QtCore.QObject)
def getLayout(layoutName):
ptr = mui.MQtUtil.findControl(layoutName)
return sip.wrapinstance(long(ptr), QtCore.QObject)
#Create our QWidgets and Layout
m_scrollArea = QtGui.QScrollArea()
#Create the window
cmds.window()
#Add PaneLayout
m_paneLayout = cmds.paneLayout( configuration='vertical2' )
#Add a standard Maya Button to the left Pane
cmds.button()
#Add a formLayout fo the right Pane
m_FormLayout = cmds.formLayout()
cmds.setParent('..')
cmds.showWindow()
#Get the name of the control in the 2'd pane
m_SecondPaneName = cmds.paneLayout(m_paneLayout, q=True, p2=True)
#Grab a reference to the 2nd panes control
m_QPane = getLayout(m_SecondPaneName)
#Set the scroll area's parent to the 2n Panes control
m_scrollArea.setParent(m_QPane)
#Show the scroll area
m_scrollArea.show()
Thanks!
- Luke