There is a QWebView class in qt, and is is used for viewing and editing the web documents.It is a main widget component of Qt webkit.

Source code

1) mywebbrowser.pro
#-------------------------------------------------
#
# Project created by QtCreator 2014-12-13T17:43:33
#
#-------------------------------------------------

QT += core gui webkitwidgets

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = mywebbrowser
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp

HEADERS += mainwindow.h

FORMS += mainwindow.ui


2) mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include<QtGui>
#include<QtWebKit/QtWebKit>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
      Q_OBJECT
      public:
          explicit MainWindow(QWidget *parent = 0);
          ~MainWindow();
       private slots:
         void on_pushButton_clicked();
       private:
          Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

3) main.cpp
#include "mainwindow.h"
#include<QApplication>

int main(int argc, char *argv[])
{
        QApplication a(argc, argv);
        MainWindow w;
        w.show();
return a.exec();
}

4) mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"

                   MainWindow::MainWindow(QWidget *parent) :
                   QMainWindow(parent),
                       ui(new Ui::MainWindow)
                       {
                               ui->setupUi(this);
                        }

MainWindow::~MainWindow()
{
            delete ui;
}

void MainWindow::on_pushButton_clicked()
{
             QString url = ui->lineEdit->text();
             ui->webView->load(url);
}

5) mainwindow.ui
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>749</width>
    <height>342</height>
   </rect>
  </property>
 <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralWidget">
   <widget class="QWidget" name="layoutWidget">
    <property name="geometry">
     <rect>
      <x>10</x>
      <y>10</y>
      <width>802</width>
      <height>639</height>
     </rect>
    </property>
    <layout class="QVBoxLayout" name="verticalLayout">
     <item>
      <layout class="QHBoxLayout" name="horizontalLayout">
       <item>
        <widget class="QLineEdit" name="lineEdit"/>
       </item>
       <item>
        <widget class="QPushButton" name="pushButton">
         <property name="text">
          <string>go</string>
         </property>
        </widget>
       </item>
      </layout>
     </item>
     <item>
      <widget class="QWebView" name="webView">
       <property name="url">
        <url>
         <string>about:blank</string>
        </url>
       </property>
      </widget>
     </item>
    </layout>
   </widget>
  </widget>
  <widget class="QMenuBar" name="menuBar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>749</width>
     <height>26</height>
    </rect>
   </property>
  </widget>
 <widget class="QToolBar" name="mainToolBar">
   <attribute name="toolBarArea">
    <enum>TopToolBarArea</enum>
   </attribute>
   <attribute name="toolBarBreak">
    <bool>false</bool>
   </attribute>
  </widget>
  <widget class="QStatusBar" name="statusBar"/>
 </widget>
 <layoutdefault spacing="6" margin="11"/>
 <customwidgets>
  <customwidget>
   <class>QWebView</class>
   <extends>QWidget</extends>
  <header>QtWebKitWidgets/QWebView</header>
  </customwidget>
 </customwidgets>
 <resources/>
 <connections/>
</ui>

*Note If any error comes related to Url then just #include<QUrl>
Screenshot-300x225



Related Contents to follow