Results 1 to 15 of 15

Thread: unable to click the hyperlink in textedit

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: unable to click the hyperlink in textedit

    Quote Originally Posted by rleojoseph View Post
    now i cant insert the baseUrl into the <a href .......> tag ???
    Why not?
    Qt Code:
    1. QString link = QString("<a href=\"%1\">%1</a>").arg(baseUrl);
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. The following user says thank you to wysota for this useful post:

    rleojoseph (7th January 2011)

  3. #2
    Join Date
    Jan 2011
    Posts
    42
    Thanks
    8
    Qt products
    Qt4 Qt/Embedded

    Default Re: unable to click the hyperlink in textedit

    ya. its working now. But i got a NEW problem now. after inserting the link in the TextEdit, the text which i am typing now is looking like a hyperlink. i have inserted a link lik www.google.com , whatever the text am typing after that it is like Hyperlink. even i tried a lot with Qtextcursor.

  4. #3
    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: unable to click the hyperlink in textedit

    Hey what's up with you? Please do not start multiple threads about the same topic, and I told you days ago to use HTML...

    And as to your new problem, you probably didn't close the a tag correct. Please show us the code.

  5. #4
    Join Date
    Jan 2011
    Posts
    42
    Thanks
    8
    Qt products
    Qt4 Qt/Embedded

    Default Re: unable to click the hyperlink in textedit

    Sorry for posting multiple threads


    here is the code

    Qt Code:
    1. bool ok;
    2. QString baseUrl= QInputDialog::getText(this, tr("URL"),tr("Link:"), QLineEdit::Normal, "", &ok);
    3. if (ok && !baseUrl.isEmpty())
    4. {
    5.  
    6. QTextCursor cursor = ui->textEdit->textCursor();
    7. //int i=cursor.position();
    8. //qDebug("%d",i);
    9. QString link = QString("<a href=\"%1\">%1</a>").arg(baseUrl);
    10.  
    11. cursor.insertHtml(link);
    To copy to clipboard, switch view to plain text mode 

    Whatever i am typing after inserting url , all the texts are becoming as hyperlink.
    Last edited by Lykurg; 7th January 2011 at 12:46. Reason: missing [code] tags

  6. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: unable to click the hyperlink in textedit

    Make sure the cursor is positioned after the link is closed. For example insert a space after closing the "a" tag. For more advanced things you'll have to use the text document and text cursor api. Bottom line is you need to make sure the current text char format is not the one associated with the link. There are many one that are likely to make it work.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. The following user says thank you to wysota for this useful post:

    rleojoseph (7th January 2011)

Similar Threads

  1. insert hyperlink(URL) inside the TextEdit..
    By rleojoseph in forum Qt Programming
    Replies: 10
    Last Post: 6th January 2011, 07:15
  2. Replies: 0
    Last Post: 2nd January 2010, 08:58
  3. Catch click Hyperlink event
    By summer_of_69 in forum Qt Programming
    Replies: 1
    Last Post: 22nd June 2009, 19:43
  4. QTextEdit for Hyperlink
    By blueteeth in forum Qt Programming
    Replies: 4
    Last Post: 1st February 2008, 09:25
  5. How to create a HyperLink in Qt?
    By vishal.chauhan in forum Newbie
    Replies: 1
    Last Post: 27th March 2007, 14:03

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
  •  
Qt is a trademark of The Qt Company.