I am working on creating a line numbers widget for a QPlainTextEdit. It is basically a QListWidget. However, I have detected a small space only above the first line of a QPlainTextEdit as you can see in my screenshot.
How can I remove this space and even know the exact height of it?
Try setting QTextDocument::setDocumentMargin()
https://doc.qt.io/qt-5/qtextdocument.html#documentMargin-prop, which you can access by calling QPlainTextEdit::document()
https://doc.qt.io/qt-5/qplaintextedit.html#document, or QPlainTextEdit::setViewportMargins()
https://doc.qt.io/qt-5/qabstractscrollarea.html#setViewportMargins to 0. I am not sure which one will work in your case, but these both can be used for creating some blank space around the document, one of them will certainly work.