Don't like ads? PRO users don't see any ads ;-)
Guest

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
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. """
  2. <name>Generic Widg</name>
  3. <description>Generic widget.</description>
  4. <icon>icons/GenIm.png</icon>
  5. <priority>40</priority>
  6. """
  7. import Orange
  8. import sys
  9. from OWWidget import OWWidget
  10. import OWGUI
  11. from cv2 import cv
  12.  
  13. ###
  14.  
  15. from PyQt4.QtCore import QAbstractListModel
  16.  
  17. class ThumbnailsListModel(QAbstractListModel):
  18.     """A model for the thumbnail view."""
  19.     def __init__(self):
  20.         self.strings = ['and','rej','neshto','drugo']
  21.    
  22.     def data(self, index, role=0): # Change role to Qt::DisplayRole enum
  23.         return self.strings[index]
  24.  
  25.     def rowCount(self, parent=0):
  26.         return len(self.strings)
  27.  
  28. ###
  29.  
  30. class OWGenericWidget(OWWidget):
  31.  
  32.     def __init__(self, parent=None, signalManager=None):
  33.         OWWidget.__init__(self, parent, signalManager, 'GenWidg')
  34.  
  35.         self.inputs = []
  36.         self.outputs = []
  37.  
  38.         # Hardcoded image paths, to be deleted
  39.         self.images = [
  40.             "/home/whoeverest/Pictures/asd.jpg",
  41.             "/home/whoeverest/Pictures/gsoc.png",
  42.             "/home/whoeverest/Pictures/the-nerd.png"
  43.         ]
  44.  
  45.         model = ThumbnailsListModel()
  46.  
  47.         thumbnails = OWGUI.QListView(self.mainArea)
  48.         thumbnails.setModel(model)
  49.         thumbnails.setGeometry(10,10,470,470)
  50.         thumbnails.setIconSize(OWGUI.QSize(100,100))
  51.         for path in self.images:
  52.             item = OWGUI.QListWidgetItem(OWGUI.QIcon(path), "")
  53.             thumbnails.addItem(item)
  54.  
  55.         self.resize(500,500)
  56.  
  57. ##############################################################################
  58. # Test the widget, run from prompt
  59.  
  60. if __name__=="__main__":
  61.     appl = OWGUI.QApplication(sys.argv)
  62.     ow = OWGenericWidget()
  63.     ow.show()
  64.     appl.exec_()