Solved CRLF QTextedit
-
@Albator I don't understand: from where does CRLF come from? From a file? Or inserted from the code?
"and me i want this CRLF to obtain two QVector<QString> w1,w2:" - https://doc.qt.io/qt-5/qtextedit.html#toPlainText and https://doc.qt.io/qt-5/qstring.html#split-5 -
if you want i write a .txt with this Qtextedit
and i want in the .txt
looooooooooooooooooo
oooooooooooogand i have
loooooooooooooooooooooooooooooooooooooooooooooong -
@Albator If you want to wrap long lines then simply set https://doc.qt.io/qt-5/qtextedit.html#lineWrapMode-prop
-
okay
visually it works but concretely it's always the same line because in my .txt i have :
long sentence test: "a long sentence that comes up against a qtextedit is to make a line break and must therefore be considered as another line".and i want in my .txt :
long sentence test: "a long sentence tha
t comes up against a qtextedit is to mak
e a line break and must therefore be con
sidered as another line". -
@Albator said in CRLF QTextedit:
and i want in my .txt :
Can you please be more precise?
Do you want to modify the content of your file now or what? -
@jsulm said in CRLF QTextedit:
Can you please be more precise?
Do you want to modify the content of your file now or what?I want the same layout of the text in qtextedit i.e. with line breaks in my .txt
but with this method "linewrap" the text have line break visually but not really but he stay the same line
and when i put the text of the qtextedit in my .txt i have just one line... -
@Albator Then you have to modify the content of your file to split long lines into shorter lines.
-
i don't want touch my .txt, i would like found a solution in the qtextedit directly
for example when i write and put in enter i obtain :
it's impossible to make a "enter keybord" automaticly to the end of frame ?
-
@Albator
Hi
QTextEdit will not alter the original text so it will always be one long line even if it shows it
"wrapped"So even if we see this on-screen.
When we ask it
auto doc = ui->textEdit->document(); for (QTextBlock it = doc->begin(); it != doc->end(); it = it.next()) qDebug() << it.text();
it gives the original text as it purely visual drawn. no newline was inserted.
"loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong"
So I don't think you can use TextEdit for this. You have to split it manually by inserting \n into the text.
-
@mrjj said in CRLF QTextedit:
So I don't think you can use TextEdit for this. You have to split it manually by inserting \n into the text.
okay :'(
i'm a little bit sadSince I want a line break every 40 characters on average, I'll force the integration of the "every 40"...
thanks you all :))
-
@Albator
Why sad? It's just insert a\n
every 40 characters, two lines of code. A couple more lines to detect where it already has line breaks and restart the count to 40 from there.QTextEdit
isn't doing anything magic/more complicated than that. -
Yes thanks
that's what I said to myself right after "my sad mood" :)