Hi all,

I'm trying to get a Icon in my model view in a standard QListview

I am running the PumpThread in maya2008 on ubuntu linux but I'm now testing this in Python Standalone and i still get the same error.

QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::setCompositionMode: Painter not active
QPainter::end: Painter not active, aborted

The UI runs but i get no icon showing, althroughi get the above error when i select the item in the listview

As far as i know i'm know i'm doing everything correctly. I only have one collum and the item is just text with a check box 'setCheckable' and i just want an icon image in the same collum as part of the same item.

I have tried different formats gif, xpm and jpg and also standard images etc but the same error occurs.

does anyone have sample code that is simple and works fine with pixmaps? or if you can see anything in my code let me know

cheers

john


to run the below code just make a .ui file mainwindow with a single listView named 'GroupList' and replace the UI_FILE Path name to point to it.

note...some lines are commented out for testing standard images and some standard maya ones

## beginning Code##

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4 import uic
import os
import sys

win = None

UI_FILE = 'PATHTOMYUIFILE.ui'

#icon='/usr/autodesk/maya2008-x64/icons/out_mesh.xpm'

cacheGroups=['Shirt_dyn', 'Shirt_hi', 'shirt_dyn', 'shirt_hi']

class MainWindow(QMainWindow):
def __init__(self, *p):
       QMainWindow.__init__(self, *p)
       uic.loadUi(UI_FILE, self)
       self.model = QStandardItemModel()
#pixmap = QPixmap(icon)
       icon = QIcon ( self.style().standardPixmap(QStyle.SP_FileIcon) )

       cacheGroups.sort()
       for i in cacheGroups:
           itm = QStandardItem(i)
           #itm.setIcon(QIcon(pixmap))
           itm.setIcon(icon)
           itm.setCheckable(True) #adds checkbox
self.model.appendRow(itm) self.GroupList.setModel(self.model)

def run():

   app = qApp
   win = MainWindow()
   win.show()


if __name__ == '__main__': # runs them Main window
   app = QApplication(sys.argv)
   mw = MainWindow()
   mw.show()
   sys.exit(app.exec_())
   print '%s done' % __file__

run()

--
http://groups.google.com/group/python_inside_maya

Reply via email to