title: QMessageBox QTextCursor::setPosition out of range
body: <p>If I execute the following code, I get the message:</p>
  
  <pre><code>QTextCursor::setPosition: Position '5' out of range
  </code></pre>
  
  <p>This is just a small example to reproduce the error message. Does any one now how to avoid this or why it happen?</p>
  
  <pre><code>from PyQt5 import QtWidgets 
  import sys
  
  class programm(QtWidgets.QMainWindow):
  
    def __init__(self):
      QtWidgets.QMainWindow.__init__(self)
  
    def message(self):
      dialog = QtWidgets.QMessageBox(self)
      dialog.setText('Test')
      dialog.setDetailedText('Test')
      dialog.setVisible(True)
  
  app = QtWidgets.QApplication(sys.argv)
  prog = programm()
  prog.show()
  prog.message()
  sys.exit(app.exec_())
  </code></pre>