You Are Here:

Community: Wiki

This page was last modified on 3 September 2009, at 07:40.

CS001429 - Using QTextBrowser in Qt

From Forum Nokia Wiki


ID CS001429 Creation date June 16, 2009
Platform S60 3rd Edition, FP1, FP2
S60 5th Edition
Tested on devices Nokia 5800 XpressMusic
Category Qt for Symbian Subcategory UI


Keywords (APIs, classes, methods, functions): QTextBrowser

Overview

This code snippet demonstrates how to use QTextBrowser. The QTextBrowser class extends QTextEdit and provides a rich text browser with hypertext navigation.

Note: In order to use this code, you need to have Qt for S60 installed on your platform.


Preconditions


Header

#include <QWidget>
#include <QTextBrowser>
#include <QVBoxLayout>
 
class MyWidget : public QWidget
{
Q_OBJECT
 
public:
MyWidget(QWidget *parent = 0);
~MyWidget();
void setText(QString);
 
private:
QTextBrowser* textBrowser;
};

Source

MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
// Create text browser
textBrowser = new QTextBrowser(this);
 
// Set it read only
textBrowser->setReadOnly(true);
 
// Do not show frames
textBrowser->setFrameStyle(true);
textBrowser->setFrameStyle(QFrame::Plain);
 
// NOTE: That allows to open links from the html code
textBrowser->setOpenExternalLinks(true);
 
// Use layout
QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(textBrowser);
setLayout(layout);
}
 
void MyWidget::setText(QString data)
{
// Set some html data into QTextBrowser
textBrowser->setHtml(data);
}
 
MyWidget::~MyWidget()
{
}


See also


Postconditions

QTextBrowser shows HTML and the device's web browser follows the link when the user selects it.

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia