继承 QObject and QTextObjectInterface .
The QPyTextObject class is provided to work around the fact that it is not possible for a Python class to derive from multiple Qt classes.
In order to create new types of text object that you can add to a QTextDocument you should implement a Python class derived from QPyTextObject rather than one derived from QObject and QTextObjectInterface .
parent argument, if not None, causes self to be owned by Qt instead of PyQt.