View Full Version : How to get text of last line only in QTextEdit?
rajesh
12th June 2006, 11:55
How to get text of last line from QTextEdit, and how to set cursor at the end of line or text? Actually I want to blink the cursor at the end of text when textedit get focus through code.
munna
12th June 2006, 12:31
You can go to any part of the document and play with it using
QTextDocument
QTextBlock
QTextCursor
and probably some other related classes.
patrik08
12th June 2006, 14:37
How to get text of last line from QTextEdit, and how to set cursor at the end of line or text? Actually I want to blink the cursor at the end of text when textedit get focus through code.
have a look on file:
http://ciz.ch/svnciz/_STATIC_LIBS_QT4/src_0/c_html_edit/html_edit.h
http://ciz.ch/svnciz/_STATIC_LIBS_QT4/src_0/c_html_edit/html_edit.cpp
this sample make a href link or unlink a text
void HTML_Edit::makehrefLink()
{
bool is_selected = html_area->textCursor().hasSelection();
QString sthtml = html_area->textCursor().selectedText();
if (vol_18->isChecked()) {
QString ltext;
if (sthtml.size() < 1) {
sthtml= "Text to link";
}
Href_Gui::self( this )->text_href->setText(sthtml);
Href_Gui::self( this )->exec();
if (Href_Gui::self) {
QStringList data = Href_Gui::_self->GetUserConfig();
if (data.count() > 0) {
/*qDebug() << "### linerr rrr " << QString(data.at(0));
qDebug() << "### linerr rrr " << QString(data.at(1));
qDebug() << "### linerr rrr " << QString(data.at(2));*/
ltext ="<a href=\""+QString(data.at(1))+"#target="+QString(data.at(2))+"\">"+QString(data.at(0))+"</a>";
QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(ltext);
html_area->textCursor().insertFragment(fragment);
vol_18->setChecked(false);
}
}
} else {
QTextDocumentFragment fragment = QTextDocumentFragment::fromHtml(sthtml);
html_area->textCursor().insertFragment(fragment);
}
}
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.