PDA

View Full Version : Adding URL to a Image



amali
8th January 2011, 16:11
Hi,am currently working on QT 4.7.
I had a doubt , is it possible to insert a link over a Image. I mean inserting the filepath into a image in QTextEdit. When i click that image the file should open. I tried my level best,i couldnt find a solution.
I tried QDesktopServices too, but i dont know how to embed a link to image.

Lykurg
8th January 2011, 16:34
Do you have posted earlier under "rleojoseph"?

Nevertheless, what do you mean by insert a filepath into an image? What's about the href attribute of the HTML A tag? And QDesktopServices is to open a file and has nothing to do with embedding.


Further: moved to newbie.

javimoya
8th January 2011, 16:39
you need to use qtextbrowser instead of qtextedit if you want to catch hiperlinks.

amali
9th January 2011, 07:03
Ya i have seen that , he is trying to insert a html into the text area.
But I was trying add many images in the TextEdit, where each image should point to one file.
Like, When i click a image a filename.txt should open, when i click another image anotherfile.txt should open. Its Like Embedding/inserting the url/path of a file OVER a Image.

Added after 5 minutes:

Its not the thing with catching the mouseevents to open a hyperlink, its about inserting a image along with the URK in the TextArea.
???

Lykurg
9th January 2011, 08:30
to insert the images use QTextCursor::insertImage(). And since images stored in the char format, you can use QTextCharFormat::setAnchorHref() for the url (See at the bottom of "Rich Text Document Structure" in the docs.). Or use the second parameter (name) of insertImage(), thus the name should be stored as the tool tip (but I am not sure about that).

amali
9th January 2011, 17:48
You are Gr8.:)