Nominate our 2022 Qt Champions!

QPlainTextEdit and indentation of wordwrapped text?

  • From the searching I've done, the impression I've gotten is this may be something QTextEdit can do, but not QPlainTextEdit due to it being stripped down for plain text, but I don't fully understand why and I thought I'd ask here in case my searches have missed something important.

    In case the title doesn't explain it, what I'm looking to do is the kind of behavior you'd see in an editor like Notepad++, where a block of text that is wordwrapped is displayed with the same indent level for each line. This appears to be something specialized to do with painting? (or whatever terminology would apply to editors like Notepad++) Since it's not an actual indent in terms of space or tab characters on lines past the 1st in the wordwrapped block, it's just painted as if it is? But that's just a guess. I don't have any familiarity with how it's done.

  • @Trapezoid_Dreams
    You won't be able to do that with plain text. It's, well, plain text, so nothing extra in it.

    With QTextEdit/QTextDocument you have HTML/Qt's "rich text". At least that can do indentation. Though it won't automatically do it in relation to word wrap per se, you will (presumably) need to put your paragraph in something which specifies a margin/indentation.

  • Gotcha, thanks for the info. Was hoping there might be some way to overcome it with special painting rules or something, but that may be like squaring a circle territory. At least now I know it's not just something I'm missing.

  • @Trapezoid_Dreams
    Well theoretically you might be able to do anything at the paint level, but I think that would be totally the wrong approach for this issue.

Log in to reply