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.)
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.)
Qt Code:
void TextPad::inserturl() { bool ok; ui->textEdit->setHtml(baseUrl); }To copy to clipboard, switch view to plain text mode
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
Last edited by Lykurg; 5th January 2011 at 09:08. Reason: missing [code] tags
Yeah, I guessed that... look:
inserts plain text even if you use setHtml. But with thatQt Code:
ui->textEdit->setHtml("http://qtcentre.org");To copy to clipboard, switch view to plain text modeyou insert HTML. You might also want to check the user input first.Qt Code:
ui->textEdit->setHtml("<a href=\"http://qtcentre.org\">http://qtcentre.org</a>");To copy to clipboard, switch view to plain text mode
rleojoseph (7th January 2011)
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(???????);
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!
rleojoseph (7th January 2011)
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!!!!
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)
rleojoseph (7th January 2011)
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.
Bookmarks