Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to retrieve text ?
Qt 6.12 LTS is out! See what's new in the release blog

How to retrieve text ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 505 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous_Banned275
    wrote on last edited by
    #1

    I have some understanding of the concept , but I really need step by step explanation what is the code doing.
    I have look at few examples and they do not explain what each class in trying to do .
    And things are more confusing since my code is already running in QTextEdit object.
    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
    verbal desription of each.

    1. QTextDocument instance does ... ( links to actuall QTextEdit "text" ? If so how ? )

    2. QTextCurson instance does... ( links to instance of QTextDocument physical cursor ?
      etc ....

      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);
    
    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by ChrisW67
      #2
      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->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->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.
      

      Nothing in this code retrieves text, so I do not see how it is related to the question posed in the title.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt
      • Unsolved