×
Namespaces

Variants
Actions
Revision as of 01:15, 11 October 2012 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Using QTextBrowser in Qt

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

Qt Quick should be used for all UI development on mobile devices. The approach described in this article (using C++ for the Qt app UI) is deprecated.

Article Metadata
Tested with
Devices(s): Nokia 5800 XpressMusic
Compatibility
Platform(s): S60 3rd Edition, FP1, FP2
S60 5th Edition
Symbian
Article
Keywords: QTextBrowser
Created: tepaa (03 Jun 2009)
Last edited: hamishwillee (11 Oct 2012)

Contents

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 installed on your platform.


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.

This page was last modified on 11 October 2012, at 01:15.
94 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×