title: How to reimplement QTextDocument createObject?
body: <p>How to reimplement <code>QTextDocument.createObject</code>?</p>
  
  <p>this method plays a role in making <code>QTextFrame</code>, <code>QTextList</code>, <code>QTextTable</code> or other <code>QTextObject</code>.</p>
  
  <p>According to <a href="https://code.woboq.org/qt5/qtbase/src/gui/text/qtextdocument.cpp.html#_ZN13QTextDocument12createObjectERK11QTextFormat" rel="nofollow noreferrer">woboq</a>, I think my reimplementation is the same.</p>
  
  <p>But kernel stops.</p>
  
  <p>Why? What is my code short of?</p>
  
  <pre><code>from PySide2 import QtWidgets
  from PySide2 import QtGui
  from PySide2 import QtCore
  import PySide2
  import sys
  import os
  dirname = os.path.dirname(PySide2.__file__)
  plugin_path = os.path.join(dirname, 'plugins', 'platforms')
  os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path
  class TextEdit(QtWidgets.QTextEdit):
      def __init__(self, parent=None):
          super(TextEdit, self).__init__(parent=None)
          document = TextDocument(self)
          self.setDocument(document)            
  class TextDocument(QtGui.QTextDocument):
      def __init__(self, parent=None):
          super(TextDocument, self).__init__(parent=None)      
          self.setParent(parent)    
      def createObject(self, f):
          obj = QtGui.QTextObject(self)
          if f.isListFormat():
              obj = QtGui.QTextList(self)
          elif f.isTableFormat():
              obj = QtGui.QTextTable(self)
          elif f.isFrameFormat():            
              obj = QtGui.QTextFrame(self)                
          return obj       
  def main():
      if QtWidgets.QApplication.instance() is not None:
          app = QtWidgets.QApplication.instance()
      else:
          app = QtWidgets.QApplication([])
      mainwindow = TextEdit()
      mainwindow.show()
      sys.exit(QtWidgets.QApplication.exec_())
  if __name__ == "__main__":
      main()
  </code></pre>