Results 1 to 6 of 6

Thread: Adding URL to a Image

  1. #1
    Join Date
    Jan 2011
    Posts
    5
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Adding URL to a Image

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Adding URL to a Image

    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.

  3. #3
    Join Date
    Jul 2009
    Posts
    74
    Thanks
    2
    Thanked 6 Times in 6 Posts

    Default Re: Adding URL to a Image

    you need to use qtextbrowser instead of qtextedit if you want to catch hiperlinks.

  4. #4
    Join Date
    Jan 2011
    Posts
    5
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding URL to a Image

    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.
    ???
    Last edited by amali; 9th January 2011 at 06:03.

  5. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Adding URL to a Image

    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).

  6. The following user says thank you to Lykurg for this useful post:

    amali (9th January 2011)

  7. #6
    Join Date
    Jan 2011
    Posts
    5
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Adding URL to a Image

    You are Gr8.

Similar Threads

  1. Adding Image to QPushButton
    By Seema Rao in forum Qt Programming
    Replies: 3
    Last Post: 18th November 2011, 09:06
  2. adding image to header column of a table view
    By nageshvk in forum Qt Programming
    Replies: 1
    Last Post: 4th May 2011, 04:14
  3. adding image into a databse using sqlite
    By pankaj.1426 in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 20th October 2010, 10:08
  4. Background image is missing after adding dlls
    By Lazaruspl in forum Qt Programming
    Replies: 10
    Last Post: 25th June 2010, 21:58
  5. Adding image in background
    By A.H.M. Mahfuzur Rahman in forum Qt Programming
    Replies: 6
    Last Post: 9th August 2009, 16:39

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.