insert hyperlink(URL) inside the TextEdit..
Hi, i can add the path to textedit area, but i want that url to be like a hyperlink. Does any1 got any idea?? All i need is that , the URL which i am inserting sholud be Clickable format.
Even i tried with the QTextBrowser and QTextCharFormat. i couldnt find out the solution.
I will be very much thankful. Pleassseeeeeeeee.
Re: insert hyperlink(URL) inside the TextEdit..
What about inserting HTML instead of plain text?
Re: insert hyperlink(URL) inside the TextEdit..
textedit.insertHtml will insert only the link/path. but the path is not highlighted like a URL. please reply if u know the answer.
Re: insert hyperlink(URL) inside the TextEdit..
I was talking about interting HTML, not inserting plain text via the setHtml function. You might also want have a look at the textInteractionFlags.
(If you would have post some code what you have tried, it would be easier to help.)
Re: insert hyperlink(URL) inside the TextEdit..
Code:
void TextPad::inserturl()
{
bool ok;
ui->textEdit->setHtml(baseUrl);
}
This is like, a dialog will open and i will enter the URL in that. aftr that the url is displayed in the textedit, but not as a hyperlink.
Waiting for ur reply
Re: insert hyperlink(URL) inside the TextEdit..
Yeah, I guessed that... look:
Code:
ui->textEdit->setHtml("http://qtcentre.org");
inserts plain text even if you use setHtml. But with that
Code:
ui->textEdit->setHtml("<a href=\"http://qtcentre.org\">http://qtcentre.org</a>");
you insert HTML. You might also want to check the user input first.
Re: insert hyperlink(URL) inside the TextEdit..
Thank u very much! That is working but the link is not like a clickable format .
This is what am going to do. Insert a URL in a TextEdit and click the link that will open in a default browser or Webview.
But my work is to load the the URL from the Dialog Box.
QString baseUrl= QInputDialog::getText(this, tr("URL"),tr("Link:"), QLineEdit::Normal, "", &ok);
ui->textEdit->setHtml(???????);
Re: insert hyperlink(URL) inside the TextEdit..
Well I won't write the program for you. See textInteractionFlags(), check for a signal which is emitted when someone clicks the link and react on that bay opening the default browser etc. See also QDesktopServices.
And NOTICE the [CODE] tags!
Re: insert hyperlink(URL) inside the TextEdit..
Thanks a lot again!! Am working on it. I have another question,If you wish you can reply. is it possible to embed a link to a image. I mean using the image as a link. Its like , embedding the link/path of a file to that image.
Thanks in Advance!!!!
Re: insert hyperlink(URL) inside the TextEdit..
Yes it is possible and all related the HTML. See the img tag: http://www.w3schools.com/tags/tag_img.asp. (Also handy: the Qt resource System)
Re: insert hyperlink(URL) inside the TextEdit..
Am workin on QT4.7. Lets say am selecting a file like *.doc and instead of opening it i am goin to insert a image/icon in a TEXTEDIT.Now when i click that IMAGE the *.doc file should open. Thats why i thought of inserting an image when a file is selected, and when i click the image the file should open.