Custom Shaped (Plain)TextEdit Or Custom WrapMode
-
Hello,
I tried to find out on my own but really couldnt find any solution so far.
I am trying to have a TextEdit Box like a notepad, but I dont want a rectangular form.
For example I might want to insert text in like a triangle shaped textedit.
Or lets imagine simply a rectangle but with a custom linewrapmode where it has different width for every line and could define a triangle in that way as well. For example, if line 0, I set linewrapmode to 50 width, line 1 -> 45 width, line2-> 40 width, line3-> 35 width, It will ultimately give me a custom shaped textedit as well, but the only options available are full WidgetWidth or NoWrap at all.
Anyway to customize that linewrapmode or to create a custom shaped textbox ?Thanks
-
It is very possible, but not easy. To shape a single paragraph into a custom shape you use
QTextLayout
directly, and there is an example in the Qt documentation. To make an editor that has an unusual shape for the text, your are going to need to useQTextEdit
with a custom implementation ofQAbstractTextDocumentLayout
. Good luck, you'll need it. -
any help pls ?
Summary :
Having a Text area with different margins on the left or right would look like this :This is some example text and I want it
.............to display for example like this
..........................because I chose to. But I
.......................................dont know how to
..................................................define it with
.................................................................QT. -
It is very possible, but not easy. To shape a single paragraph into a custom shape you use
QTextLayout
directly, and there is an example in the Qt documentation. To make an editor that has an unusual shape for the text, your are going to need to useQTextEdit
with a custom implementation ofQAbstractTextDocumentLayout
. Good luck, you'll need it. -