title: PyQt model of complex class
body: <p>I have a Python class with attributes that aren't as simple as the very limited set of PyQt Model/View examples I can find:</p>
  
  <pre><code>class my_data_class(object):
      def __init__(self,name='default',index=0):
          self.name = name
          self.index = index
          # self.data is a variable length list of dictonaries
          self.data = [{'dataset_name':'table1', 'x':[1.0,2.0,3.0], 'y':[4.0,5.0,6.0]},
                       {'dataset_name':'table2', 'x':[5.0,2.0,3.1], 'y':[1.1,1.0,1.0]}]
  </code></pre>
  
  <p>I'd like to make a viewing/editing form for this class instance that looks like this: </p>
  
  <p><a href="https://i.stack.imgur.com/ZSjSw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZSjSw.png" alt="gui editor/viewer for the above class definition"></a></p>
  
  <p>I read the Qt C++ model/view tutorial <a href="http://doc.qt.io/qt-4.8/modelview.html" rel="nofollow noreferrer">here</a> and the combo widget mapper C++ tutorial <a href="http://doc.qt.io/qt-4.8/qt-itemviews-combowidgetmapper-example.html" rel="nofollow noreferrer">here</a>, but I'm not seeing anything for anything more complex than a table. <a href="https://stackoverflow.com/questions/16772374/python-pyqt-mvc-pattern-model-class-to-work-with-view-and-object">This SO answer</a> also mentions using the <code>QDataWidgetMapper</code>, but I have no idea how to use that for a structure like this class instance. </p>
  
  <p>Should I be using multiple models to represent the single class instance? One for each view or something? That seems messy. Should I define a custom widget to define essentially a collection of simpler widgets? Not sure how that would work either. Maybe subclass <code>QModelIndex</code> somehow to allow finding data within a general class and not be limited to <code>row()</code> and <code>column()</code>? </p>
  
  <p><strong>I can't be the first one who wanted a PyQt editor/viewer for populating a complex class. What's the best way to go about this?</strong></p>