I searched the day and did not find the answer to this question. This thread How to get currently visible text from a QTextEdit or QPlainTextEdit widget? just answers how to get ALL the text contained in the widgets.
In my situation, I have a QTextWidget with lots of text. Much more than can be displayed at any given time. I would like to respond to the visible text, and then take some action.
When a user scrolls a text area or adds new text to a widget, I would like to take some action on the visible text. I can easily connect to the signal from QTextEdit :: verticalScrollBar (), but how to find what is visible text?
I have it so far, but after reading the pages and the documentation pages, it seems that QTextEdit has no way to tell you that the text is in the visible area.
void MyProject::on_textEdit_scrollBar_valueChanged(int value)
{
QStringList visibleText =
}
source
share