3

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: http://i.stack.imgur.com/ovIrJ.png.
(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.

I know this is kind of a trivial thing but its really been annoying me for a while now.

Thanks in advance for any help!

4

1 回答 1

9

使用QTextDocument::setDocumentMargin()。将其设置为零可以解决问题。要获得QTextDocument有一个方法QPlainTextEdit::document()

于 2014-10-18T17:46:12.690 回答