| 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 |
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.
#include <QWidget>
#include <QTextBrowser>
#include <QVBoxLayout>
class MyWidget : public QWidget
{
Q_OBJECT
public:
MyWidget(QWidget *parent = 0);
~MyWidget();
void setText(QString);
private:
QTextBrowser* textBrowser;
};
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()
{
}
QTextBrowser shows HTML and the device's web browser follows the link when the user selects it.
No related wiki articles found