<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to retrieve text ?]]></title><description><![CDATA[<p dir="auto">I have some understanding of the concept , but I really need step by step explanation what is the code doing.<br />
I have look at few examples and they do not explain what each class in trying to do .<br />
And things are more confusing since my code is already running  in QTextEdit object.<br />
It would help to know  what is each lineof code doing. At this point I am not concerned if the code copiles , I just need<br />
verbal desription of each.</p>
<ol>
<li>
<p dir="auto">QTextDocument   instance does ... ( links to actuall QTextEdit "text" ?  If so how ? )</p>
</li>
<li>
<p dir="auto">QTextCurson        instance does... ( links to instance of  QTextDocument physical cursor ?<br />
etc ....</p>
</li>
</ol>
<pre><code>  QTextDocument *document = new QTextDocument();
  QTextCursor cursor(document);
 // put visible cursor to the end of the line
  QTextCursor cursor = QTextEdit::textCursor();
  cursor.movePosition(QTextCursor::StartOfLine); //::End);
  setTextCursor(cursor);
</code></pre>
]]></description><link>https://forum.qt.io/topic/139371/how-to-retrieve-text</link><generator>RSS for Node</generator><lastBuildDate>Sat, 24 Oct 2026 18:06:14 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139371.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 16 Sep 2022 14:15:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to retrieve text ? on Sun, 18 Sep 2022 01:08:01 GMT]]></title><description><![CDATA[<pre><code>QTextDocument *document = new QTextDocument();  
// ^^^ a new empty QTextDocument

QTextCursor cursor(document); 
// ^^^ an object that represents  position in the text of the document above (there is none)

// put visible cursor to the end of the line
//     ^^^ A QTextDocument is an in-memory structure representing a document, there is no "visible"

QTextCursor cursor = QTextEdit::textCursor();
// ^^^ This should not compile, there is no static QTextEdit::textCursor()
// If you went:
QTextCursor cursor = textEdit-&gt;textCursor();
// then you would have an object that represented a location within the document that 
// the text edit is currently displaying a visible cursor at.  
// This is *not* the document created above.
// The QTextDocument being displayed by a QTextEdit is obtained with textEdit-&gt;document()
// https://doc.qt.io/qt-6/qtextedit.html#document-prop

cursor.movePosition(QTextCursor::StartOfLine);
// Move the cursor object to point at the start of the line in the QTextDocument 
// object it is related to.  
// This does *not* move the visible cursor in the QTextEdit.

setTextCursor(cursor);
// Assuming this is called on the textEdit object then the visible cursor should
// move to the location corresponding to the cursor object's location in the document.
// In this case, where the start of the document line is present on the screen.
// A document line , and a line on screen, do not necessarily mean the same thing 
// because a single document line can be wrapped.
</code></pre>
<p dir="auto">Nothing in this code retrieves text, so I do not see how it is related to the question posed in the title.</p>
]]></description><link>https://forum.qt.io/post/729133</link><guid isPermaLink="true">https://forum.qt.io/post/729133</guid><dc:creator><![CDATA[ChrisW67]]></dc:creator><pubDate>Sun, 18 Sep 2022 01:08:01 GMT</pubDate></item></channel></rss>