QPlainTextEdit any way to fill line until the widget end?

  • When printing text with less characters than a line could store (say 70 out of 80) I would like to fill the remaining characters (say 10) with whitespaces. I am using a fixed size font although, the widget is not fixed size, so I can't figure in advance how many chars would that be.
    Does QPlainTextEdit provide any functionality to automatically fill until the end of the line?

  • Lifetime Qt Champion


    I'm not aware of such a feature.

    Out of curiosity, what is your use case ?

  • I am simply printing text messages in a custom debugging console that uses a QPlainTextEdit to show the messages. After some processing I have a final QString to print, which uses HTML formatting to paint the background with a custom color. Unfortunately, if the the string length doesn't cover a full line, the remaining (inexistent) characters will use the normal widget background color instead of the color used for the text background.
    This problem is related to one of my previous threads:
    As a solution to the thread above, I thought I could fill a line with spaces so it would get fully painted.

Log in to reply