I'm using C++ and Qt on Windows to create a simple application which outputs some data to the screen using a QPlainTextEdit
.
The problem is that there is a small internal margin between the QPlainTextEdit
's border and the text as shown here:
The text in the QPlainTextEdit
has been selected to highlight the gap.
I have tried using setContentsMargins(0, 0, 0, 0)
and setStyleSheet("padding:0;")
, and using a QTextEdit
or a QTextBrowser
instead, but I still get that small margin.
Googling it only turned up this unanswered question on qtcentre.org.
Use QTextDocument::setDocumentMargin()
. Setting it to zero does the trick. To obtain QTextDocument
there's a method QPlainTextEdit::document()
.