PDA

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



huydo
14th June 2016, 21:12
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();

ChrisW67
14th June 2016, 21:54
You mean somehting like this?


QString plainText("some plain\ntext");
QString url("http://example.com");
QString html = QString("<pre>%1</pre><a href='%2'>%2</a>").arg(plainText).arg(url);
ui->textBrowser->setHtml(html);

huydo
15th June 2016, 10:48
Yeah, it is the solution for my question. Thank you so much !!
But may I can change font of plaintext ??

d_stranz
15th June 2016, 17:29
Use this link to the Qt documentation (http://doc.qt.io/qt-5.6/richtext-html-subset.html) to find the answers to your questions. You'll have to research the HTML4 documentation (https://www.w3.org/TR/html401/) if you don't know how to use these HTML tags.