Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
None
-
None
Description
I want to change QTextEdit's line-breaking algorithm so that text I'm displaying that is not English (it's code, in fact) gets wrapped in a better way. The definition of what a "word" is in Qt may be well-suited for human languages, but it is not well-suited for code, and so long lines of code end up getting wrapped at really bad places. For example, this single line of code:
- (void)setRecombinationRate(numeric rates, [Ni ends = NULL], [string$ sex = "*"])
gets wrapped by QTextEdit, in a narrow window, to this:
-
(void)setRecombinationRate(numeri
c rates, [Ni ends = NULL], [string
$ sex = "*"])
I would like to tailor the line-breaking algorithm to achieve something more like this:
- (void)setRecombinationRate(
numeric rates, [Ni ends = NULL],
[string$ sex = "*"])
I have done much the same thing in Cocoa with an override of -lineBreakBeforeIndex:withinRange: in a subclass of NSTextStorage; but there seems to be no comparable place for me to override the default behavior in Qt.
Note that I know you can customize Qt's layout so that text flows around obstacles within the QTextEdit; that is not what I'm asking about. :->