Unsolved QTextCursor changing place with find function in QPlainTextEdit
-
bool QPlainTextEdit::find(const QString &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags())
Finds the next occurrence of the string, exp, using the given options. Returns true if exp was found and changes the cursor to select the match; otherwise returns false.In this I have a QTextCursor and I want to change the position of the QtextCursor to the place where the text takes place but in the description I do not see any argument but it says it does return the cursor but my QTextCursor place does not change.
-
Hi,
Can you show how you are using QCursor with find ?
-
I am trying to use QTextCursor as to then highlight the text
-
basically I am trying to use QTextCursor to find a text and highlight it yellow
-
QString qstr4 = QString::fromStdString(tokens2.at(machine.line2 + 1));
u = text->find(qstr4, QTextDocument::FindCaseSensitively);
qDebug() << text->cursor().pos() << endl;
cursor.mergeCharFormat(format);
cout << cursor.position() << endl;but cout cur.position always gives me -1
-
I don't see any check regarding the success of the find.
-
it does highlight the text gray when it is selected but how can I change it to yellow?
-
@Rajarshi
Hi
Look here
https://forum.qt.io/topic/89365/trying-to-select-one-line-in-qplaintextedit-using-qtextcursor/5
It color it red but you can just change color used.