Archived:Web Browser in Qt for Symbian
Archived: 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 (based on QWidget) is deprecated.
Qt Quick should be used for all UI development on mobile devices. The approach described in this article (based on QWidget) is deprecated.
This code example demonstrates a simple Web Browser based on QWebView. The browser only supports HTTP (not HTTPS).
Article Metadata
Tested with
SDK: Qt v4.5
Devices(s): Qt Creator IDE & Emulator
Compatibility
Platform(s): S60 3rd Edition FP1, S60 3rd Edition FP2, S60 5th Edition
Article
Keywords: QWebView
Created: mind_freak
(12 Mar 2009)
Last edited: hamishwillee
(11 Oct 2012)
Contents |
Compatibility
- This Source code is compatible with Qt v4.5 with minor upgrade of functions.
Recommendation
- Please include QWebkit and QNetwork during code developing.
Source Code
#include "webBrowserDialog.h"
webBrowserDialog::webBrowserDialog(QWidget *parent)
: QWidget(parent)
{
lay=new QGridLayout();
back=new QPushButton("<<");
back->setToolTip("Back");
bar = new QStatusBar();
bar->resize(50,10);
progress=new QProgressBar();
progress->setTextVisible(0);
label=new QLabel();
progress->setMinimum(0);
progress->setMaximum(100);
bar->addWidget(progress);
progress->resize(10,10);
forward=new QPushButton(">>");
forward->setToolTip("Forward");
reload=new QPushButton("Reload");
reload->setToolTip("Reload");
stop=new QPushButton("X");
stop->setToolTip("Stop");
web=new QWebView();
load=new QPushButton("Load");
load->setToolTip("Load");
line=new QLineEdit("http://www.developer.nokia.com");
line->setToolTip("Type Your Address Here");
tool=new QToolBar();
bar->addWidget(progress);
bar->addWidget(label);
tool->addWidget(back);
tool->addWidget(forward);
tool->addWidget(reload);
tool->addWidget(stop);
tool->addWidget(line);
tool->addWidget(load);
lay->addWidget(tool,0,0);
lay->addWidget(web,1,0);
lay->addWidget(bar,2,0);
web->load(QUrl("http://www.developer.nokia.com"));
web->show();
QObject::connect(back,SIGNAL(clicked()),web,SLOT(back()));
QObject::connect(forward,SIGNAL(clicked()),web,SLOT(forward()));
QObject::connect(stop,SIGNAL(clicked()),web,SLOT(stop()));
QObject::connect(reload,SIGNAL(clicked()),web,SLOT(reload()));
QObject::connect(load,SIGNAL(clicked()),this,SLOT(viral()));
QObject::connect(web,SIGNAL(loadProgress(int)),progress,SLOT(setValue(int)));
setLayout(lay);
showMaximized();
}
webBrowserDialog::~webBrowserDialog()
{
}
void webBrowserDialog::viral()
{
QString str;
str=line->text();
web->load(QUrl(str));
web->show();
setWindowTitle(str);
QObject::connect(web,SIGNAL(loadProgress(int)),progress,SLOT(setValue(int)));
QObject::connect(web,SIGNAL(statusBarMessage(QString)),bar,SLOT(showMessage(QString)));
}
Header File
#include <QtGui/QWidget>
#include "ui_webBrowserDialog.h"
#include<QWidget>
#include<QWebView>
#include<QLineEdit>
#include<QGridLayout>
#include<QUrl>
#include<QPushButton>
#include<QToolBar>
#include<QString>
#include<QStatusBar>
#include<QProgressBar>
#include<QLabel>
class webBrowserDialog : public QWidget
{
Q_OBJECT
public:
webBrowserDialog(QWidget *parent = 0);
~webBrowserDialog();
private slots:
void viral();
private:
QGridLayout *lay;
QPushButton *back;
QPushButton *forward;
QPushButton *reload;
QPushButton *stop;
QWebView *web;
QPushButton *load;
QLineEdit *line;
QToolBar *tool;
QStatusBar *bar;
QProgressBar *progress;
QLabel *label;
QWidget *win;
};
#endif // WEBBROWSERDIALOG_H
Screenshots
- Emulator Look..
- Opening.... developer.nokia.com
- Opening.... Yahoo.com page


12 Sep
2009
20 Sep
2009
24 Sep
2009