Results 1 to 4 of 4

Thread: using settext() and sethtml() to display output in text browser at same time

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2016
    Posts
    2
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Question using settext() and sethtml() to display output in text browser at same time

    Hello,
    I am newbie in qt.
    I want to ask that how I can display output text and a link in html in text browser when I use settext() and setHtml();

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,590
    Thanks
    13
    Thanked 1,586 Times in 1,515 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: using settext() and sethtml() to display output in text browser at same time

    You mean somehting like this?
    Qt Code:
    1. QString plainText("some plain\ntext");
    2. QString url("http://example.com");
    3. QString html = QString("<pre>%1</pre><a href='%2'>%2</a>").arg(plainText).arg(url);
    4. ui->textBrowser->setHtml(html);
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to ChrisW67 for this useful post:

    huydo (15th June 2016)

  4. #3
    Join Date
    Jun 2016
    Posts
    2
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: using settext() and sethtml() to display output in text browser at same time

    Yeah, it is the solution for my question. Thank you so much !!
    But may I can change font of plaintext ??

  5. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,307
    Thanks
    244
    Thanked 678 Times in 668 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: using settext() and sethtml() to display output in text browser at same time

    Use this link to the Qt documentation to find the answers to your questions. You'll have to research the HTML4 documentation if you don't know how to use these HTML tags.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Real time display of QProcess output in a textBrowser
    By Tanny007 in forum Qt Programming
    Replies: 2
    Last Post: 17th December 2015, 05:30
  2. How to display text from a file to a text browser
    By ironmantis7x in forum Newbie
    Replies: 11
    Last Post: 14th June 2012, 16:23
  3. display in text browser
    By mecrazycoder in forum Newbie
    Replies: 7
    Last Post: 13th December 2010, 17:49
  4. I don't get expected output in text browser
    By NewLegend in forum Qt Programming
    Replies: 14
    Last Post: 25th July 2010, 10:21
  5. Replies: 52
    Last Post: 10th December 2006, 15:32

Tags for this Thread

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.