Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] QTextCursor - programed selection doesn't work...

[SOLVED] QTextCursor - programed selection doesn't work...

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.2k 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.
  • P Offline
    P Offline
    Peppy
    wrote on last edited by
    #1

    Hi folks, I have troubles with this code:
    @
    QString CommanderEdit::get_last_text(unsigned int from,
    unsigned int to)
    {
    textCursor().setPosition(from, QTextCursor::KeepAnchor);
    textCursor().setPosition(to);
    textCursor().select(QTextCursor::BlockUnderCursor);

    qDebug() << from << to << endl;
    qDebug() << "From: " << textCursor().selectionStart();
    qDebug() << "To: " << textCursor().selectionEnd();
    qDebug() << textCursor().selectedText();
    
    return textCursor().selectedText();
    

    }
    @

    I want to return the selected text (text is selected by program) but it always returns empty string...I am disgusted of non-working copying text - where I have done some dumb thing?...Thanks.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      Peppy
      wrote on last edited by
      #2

      Solved: just needed setTextCursor(...)

      1 Reply Last reply
      0

      • Login

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