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



  • 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.



  • Solved: just needed setTextCursor(...)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.