title: PyQt5 QTextEdit live HTML preview while editing
body: <p>I am trying to edit a QTextEdit named self.chatTextField to display the HTML preview in a live format. For example if I do "" I want it to not show the tag, but bold the text. I am able to have this work if I use textBrowswer as a previewer, but I would like it all to be in one widget.</p>
  
  <p><a href="https://i.stack.imgur.com/rQkAC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rQkAC.png" alt="enter image description here"></a></p>
  
  <p>As you can see in the image above, I want match the part the displays the HTML as final product and not the tags. Is this possible? </p>
  
  <p>I have tried various ways to convert .toPlainText() and then adding an HTML header and footer. I have tried to .insertHtml() and .setHtml(). I have tried to do tricks with open and close carrots, but nothing seems to be working. I am either getting it to simply remove all HTML (anything with carrots/tags) or it is causing recursion errors. </p>
  
  <p>This is the only section of code that is dealing with updating the HTML. If you need further code please let me know. I can provide UI file as well.</p>
  
  <pre><code>def printMaster(self):
      global my_text
  
      if self.chatTextField.toPlainText() != "":
          oldText = self.chatTextField.toPlainText()
          newText = self.textBrowser.toPlainText()
          if oldText != newText and oldText != my_text:
              self.textBrowser.setText(self.chatTextField.toPlainText())
              my_text = self.chatTextField.toPlainText()
              if my_text.endswith('&gt;'):
                  #my_text = self.chatTextField.toHtml()
  
                  # self.chatTextField.clear()
                  print(my_text)
                  # self.chatTextField.setHtml(my_text)
                  QCoreApplication.processEvents()
  
  
  
              # cursor = self.chatTextField.textCursor()
              # pos = cursor.selectionEnd()
              #
              # print(self.chatTextField.toHtml())
              #
              # my_text = self.chatTextField.toHtml()
              #
              # self.chatTextField.clear()
              # # self.chatTextField.insertHtml(str(my_text))
              #
              # if my_text.endswith('&lt;'):
              #     my_text = my_text + "&lt;"
              #     self.chatTextField.setHtml(my_text)
              #     print(True)
              # else:
              #     self.chatTextField.insertHtml(my_text)
              #
              #
              # cursor.setPosition(pos)
              #
              # self.chatTextField.setTextCursor(cursor)
              #
              #
              # QCoreApplication.processEvents()
              #
              # # self.chatTextField.show()
  </code></pre>