
Qt: RuntimeError: underlying C/C++ object has been deleted
By: a guest on
May 31st, 2012 | syntax:
Python | size: 1.72 KB | hits: 26 | expires: Never
"""
<name>Generic Widg</name>
<description>Generic widget.</description>
<icon>icons/GenIm.png</icon>
<priority>40</priority>
"""
import Orange
import sys
from OWWidget import OWWidget
import OWGUI
from cv2 import cv
###
from PyQt4.QtCore import QAbstractListModel
class ThumbnailsListModel(QAbstractListModel):
"""A model for the thumbnail view."""
def __init__(self):
self.strings = ['and','rej','neshto','drugo']
def data(self, index, role=0): # Change role to Qt::DisplayRole enum
return self.strings[index]
def rowCount(self, parent=0):
return len(self.strings)
###
class OWGenericWidget(OWWidget):
def __init__(self, parent=None, signalManager=None):
OWWidget.__init__(self, parent, signalManager, 'GenWidg')
self.inputs = []
self.outputs = []
# Hardcoded image paths, to be deleted
self.images = [
"/home/whoeverest/Pictures/asd.jpg",
"/home/whoeverest/Pictures/gsoc.png",
"/home/whoeverest/Pictures/the-nerd.png"
]
model = ThumbnailsListModel()
thumbnails = OWGUI.QListView(self.mainArea)
thumbnails.setModel(model)
thumbnails.setGeometry(10,10,470,470)
thumbnails.setIconSize(OWGUI.QSize(100,100))
for path in self.images:
item = OWGUI.QListWidgetItem(OWGUI.QIcon(path), "")
thumbnails.addItem(item)
self.resize(500,500)
##############################################################################
# Test the widget, run from prompt
if __name__=="__main__":
appl = OWGUI.QApplication(sys.argv)
ow = OWGenericWidget()
ow.show()
appl.exec_()