Hi all, I have just started learning on pyqt4 model/view and I had thought 
of trying out a very simple code to populate maya items into a QListView. 
As I run the following code in an editor (without those maya 
modules/lines), I am able to see QListView being called and populated with 
the information.

As soon as I tried running the code in Maya, the session keeps crashing on 
me unless I comment out the lines on 'app' and 'sys.exit'
But even so, if those lines are commented out, while it does pops up a 
window, nothing was populated within.

Can someone kindly advise?

# PyQt4 Modules
from PyQt4 import QtGui, QtCore, uic
import sip
import sys
import maya.cmds as cmds
import maya.OpenMayaUI as mui

def getMayaWindow():
    ptr = mui.MQtUtil.mainWindow()
    return sip.wrapinstance(long(ptr), QtCore.QObject)

def main():
    dialog = BasicDialog()
class BasicDialog(QtGui.QDialog):
    def __init__(self, parent=getMayaWindow()):
        super(BasicDialog, self).__init__(parent)
        #app = QtGui.QApplication(sys.argv)
        # Data
        data = QtCore.QStringList()     
        #data << "one" << "two" << "three" << "four" << "five"   
        geos = cmds.ls(type = "mesh")
        sel = cmds.listRelatives(geos, parent = True)
        for item in sel:
        # Model
        model = QtGui.QStringListModel(data)
        listView = QtGui.QListView()

You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
For more options, visit https://groups.google.com/d/optout.

Reply via email to