CopperSpice API  1.7.2
QWebView Class Reference

The QWebView class provides a widget that is used to view and edit web documents. More...

Inheritance diagram for QWebView:
QWidget QObject QPaintDevice

Public Signals

void iconChanged ()
 
void linkClicked (const QUrl &un_named_arg1)
 
void loadFinished (bool ok)
 
void loadProgress (int progress)
 
void loadStarted ()
 
void selectionChanged ()
 
void statusBarMessage (const QString &text)
 
void titleChanged (const QString &title)
 
void urlChanged (const QUrl &un_named_arg1)
 
- Public Signals inherited from QWidget
void customContextMenuRequested (const QPoint &pos)
 
void windowIconChanged (const QIcon &icon)
 
void windowIconTextChanged (const QString &iconText)
 
void windowTitleChanged (const QString &title)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Slots

void back ()
 
void forward ()
 
void reload ()
 
void stop ()
 
- Public Slots inherited from QWidget
bool close ()
 
void hide ()
 
void lower ()
 
void raise ()
 
void repaint ()
 
void setDisabled (bool disable)
 
void setEnabled (bool enable)
 
void setFocus ()
 
void setHidden (bool hidden)
 
void setStyleSheet (const QString &styleSheet)
 
virtual void setVisible (bool visible)
 
void setWindowModified (bool modified)
 
void setWindowTitle (const QString &title)
 
void show ()
 
void showFullScreen ()
 
void showMaximized ()
 
void showMinimized ()
 
void showNormal ()
 
void update ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 QWebView (QWidget *parent=0)
 
virtual ~QWebView ()
 
bool event (QEvent *) override
 
bool findText (const QString &subString, QWebPage::FindFlags options=0)
 
QWebHistoryhistory () const
 
QVariant inputMethodQuery (Qt::InputMethodQuery property) const override
 
void load (const QNetworkRequest &request, QNetworkAccessManager::Operation operation=QNetworkAccessManager::GetOperation, const QByteArray &body=QByteArray ())
 
void load (const QUrl &url)
 
QWebPagepage () const
 
QActionpageAction (QWebPage::WebAction action) const
 
void setContent (const QByteArray &data, const QString &mimeType=QString (), const QUrl &baseUrl=QUrl ())
 
void setHtml (const QString &html, const QUrl &baseUrl=QUrl ())
 
void setPage (QWebPage *page)
 
void setRenderHint (QPainter::RenderHint hint, bool enabled=true)
 
void setTextSizeMultiplier (qreal factor)
 
QWebSettingssettings () const
 
QSize sizeHint () const override
 
qreal textSizeMultiplier () const
 
void triggerPageAction (QWebPage::WebAction action, bool checked=false)
 
- Public Methods inherited from QWidget
 QWidget (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag)
 
 ~QWidget ()
 
bool acceptDrops () const
 
QString accessibleDescription () const
 
QString accessibleName () const
 
QList< QAction * > actions () const
 
void activateWindow ()
 
void addAction (QAction *action)
 
void addActions (const QList< QAction * > &actions)
 
void adjustSize ()
 
bool autoFillBackground () const
 
QPalette::ColorRole backgroundRole () const
 
QBackingStorebackingStore () const
 
QSize baseSize () const
 
QWidget * childAt (const QPoint &position) const
 
QWidget * childAt (int x, int y) const
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
void clearFocus ()
 
void clearMask ()
 
QMargins contentsMargins () const
 
QRect contentsRect () const
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
QCursor cursor () const
 
WId effectiveWinId () const
 
void ensurePolished () const
 
Qt::FocusPolicy focusPolicy () const
 
QWidget * focusProxy () const
 
QWidget * focusWidget () const
 
const QFontfont () const
 
QFontInfo fontInfo () const
 
QFontMetrics fontMetrics () const
 
QPalette::ColorRole foregroundRole () const
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 
QPixmap grab (const QRect &rectangle=QRect (QPoint (0, 0), QSize (-1,-1)))
 
void grabGesture (Qt::GestureType gestureType, Qt::GestureFlags flags=Qt::GestureFlags ())
 
void grabKeyboard ()
 
void grabMouse ()
 
void grabMouse (const QCursor &cursor)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 
QGraphicsEffectgraphicsEffect () const
 
QGraphicsProxyWidgetgraphicsProxyWidget () const
 
bool hasEditFocus () const
 
bool hasFocus () const
 
virtual bool hasHeightForWidth () const
 
bool hasMouseTracking () const
 
int height () const
 
virtual int heightForWidth (int width) const
 
Qt::InputMethodHints inputMethodHints () const
 
void insertAction (QAction *before, QAction *action)
 
void insertActions (QAction *before, QList< QAction * > actions)
 
bool isActiveWindow () const
 
bool isAncestorOf (const QWidget *child) const
 
bool isEnabled () const
 
bool isEnabledTo (const QWidget *parent) const
 
bool isEnabledToTLW () const
 
bool isFullScreen () const
 
bool isHidden () const
 
bool isMaximized () const
 
bool isMinimized () const
 
bool isModal () const
 
bool isTopLevel () const
 
bool isVisible () const
 
bool isVisibleTo (const QWidget *parent) const
 
bool isWindow () const
 
bool isWindowModified () const
 
QLayoutlayout () const
 
Qt::LayoutDirection layoutDirection () const
 
QLocale locale () const
 
QPoint mapFrom (const QWidget *parent, const QPoint &pos) const
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapFromParent (const QPoint &pos) const
 
QPoint mapTo (const QWidget *parent, const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QPoint mapToParent (const QPoint &pos) const
 
QRegion mask () const
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
virtual QSize minimumSizeHint () const
 
int minimumWidth () const
 
void move (const QPoint &point)
 
void move (int x, int y)
 
QWidget * nativeParentWidget () const
 
QWidget * nextInFocusChain () const
 
QRect normalGeometry () const
 
void overrideWindowFlags (Qt::WindowFlags flags)
 
QPaintEnginepaintEngine () const override
 
const QPalettepalette () const
 
QWidget * parentWidget () const
 
QPoint pos () const
 
QWidget * previousInFocusChain () const
 
QRect rect () const
 
void releaseKeyboard ()
 
void releaseMouse ()
 
void releaseShortcut (int id)
 
void removeAction (QAction *action)
 
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren))
 
void render (QPainter *painter, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren))
 
void repaint (const QRect &rect)
 
void repaint (const QRegion &region)
 
void repaint (int x, int y, int w, int h)
 
void resize (const QSize &size)
 
void resize (int w, int h)
 
bool restoreGeometry (const QByteArray &geometry)
 
QByteArray saveGeometry () const
 
void scroll (int dx, int dy)
 
void scroll (int dx, int dy, const QRect &rect)
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute attribute, bool enable=true)
 
void setAutoFillBackground (bool enable)
 
void setBackgroundRole (QPalette::ColorRole role)
 
void setBaseSize (const QSize &size)
 
void setBaseSize (int basew, int baseh)
 
void setContentsMargins (const QMargins &margins)
 
void setContentsMargins (int left, int top, int right, int bottom)
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &cursor)
 
void setEditFocus (bool enable)
 
void setFixedHeight (int h)
 
void setFixedSize (const QSize &size)
 
void setFixedSize (int w, int h)
 
void setFixedWidth (int w)
 
void setFocus (Qt::FocusReason reason)
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *widget)
 
void setFont (const QFont &font)
 
void setForegroundRole (QPalette::ColorRole role)
 
void setGeometry (const QRect &rect)
 
void setGeometry (int x, int y, int w, int h)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *layout)
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &bitmap)
 
void setMask (const QRegion &region)
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &size)
 
void setMaximumSize (int maxw, int maxh)
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &size)
 
void setMinimumSize (int minw, int minh)
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &palette)
 
void setParent (QWidget *parent)
 
void setParent (QWidget *parent, Qt::WindowFlags flags)
 
void setShortcutAutoRepeat (int id, bool enable=true)
 
void setShortcutEnabled (int id, bool enable=true)
 
void setSizeIncrement (const QSize &size)
 
void setSizeIncrement (int w, int h)
 
void setSizePolicy (QSizePolicy policy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 
void setStatusTip (const QString &data)
 
void setStyle (QStyle *style)
 
void setToolTip (const QString &data)
 
void setToolTipDuration (int msec)
 
void setUpdatesEnabled (bool enable)
 
void setWhatsThis (const QString &str)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlags (Qt::WindowFlags flags)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &role)
 
void setWindowState (Qt::WindowStates windowState)
 
QSize size () const
 
QSize sizeIncrement () const
 
QSizePolicy sizePolicy () const
 
void stackUnder (QWidget *widget)
 
QString statusTip () const
 
QStylestyle () const
 
QString styleSheet () const
 
bool testAttribute (Qt::WidgetAttribute attribute) const
 
QString toolTip () const
 
int toolTipDuration () const
 
QWidget * topLevelWidget () const
 
bool underMouse () const
 
void ungrabGesture (Qt::GestureType gestureType)
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update (const QRect &rect)
 
void update (const QRegion &region)
 
void update (int x, int y, int w, int h)
 
void updateGeometry ()
 
bool updatesEnabled () const
 
QRegion visibleRegion () const
 
QString whatsThis () const
 
int width () const
 
QWidget * window () const
 
QString windowFilePath () const
 
Qt::WindowFlags windowFlags () const
 
QWindowwindowHandle () const
 
QIcon windowIcon () const
 
Qt::WindowModality windowModality () const
 
qreal windowOpacity () const
 
QString windowRole () const
 
Qt::WindowStates windowState () const
 
QString windowTitle () const
 
Qt::WindowType windowType () const
 
WId winId () const
 
int x () const
 
int y () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &objName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 
- Public Methods inherited from QPaintDevice
virtual ~QPaintDevice ()
 
int colorCount () const
 
int depth () const
 
int devicePixelRatio () const
 
qreal devicePixelRatioF () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 

Protected Methods

void changeEvent (QEvent *) override
 
void contextMenuEvent (QContextMenuEvent *) override
 
virtual QWebView * createWindow (QWebPage::WebWindowType type)
 
void dragEnterEvent (QDragEnterEvent *) override
 
void dragLeaveEvent (QDragLeaveEvent *) override
 
void dragMoveEvent (QDragMoveEvent *) override
 
void dropEvent (QDropEvent *) override
 
void focusInEvent (QFocusEvent *) override
 
bool focusNextPrevChild (bool next) override
 
void focusOutEvent (QFocusEvent *) override
 
void inputMethodEvent (QInputMethodEvent *) override
 
void keyPressEvent (QKeyEvent *) override
 
void keyReleaseEvent (QKeyEvent *) override
 
void mouseDoubleClickEvent (QMouseEvent *) override
 
void mouseMoveEvent (QMouseEvent *) override
 
void mousePressEvent (QMouseEvent *) override
 
void mouseReleaseEvent (QMouseEvent *) override
 
void paintEvent (QPaintEvent *) override
 
void resizeEvent (QResizeEvent *) override
 
void wheelEvent (QWheelEvent *) override
 
- Protected Methods inherited from QWidget
virtual void actionEvent (QActionEvent *event)
 
virtual void closeEvent (QCloseEvent *event)
 
void create (WId window=0, bool initializeWindow=true, bool destroyOldWindow=true)
 
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
 
virtual void enterEvent (QEvent *event)
 
bool event (QEvent *event) override
 
bool focusNextChild ()
 
bool focusPreviousChild ()
 
virtual void hideEvent (QHideEvent *event)
 
void initPainter (QPainter *painter) const override
 
virtual void leaveEvent (QEvent *event)
 
int metric (PaintDeviceMetric metric) const override
 
virtual void moveEvent (QMoveEvent *event)
 
virtual bool nativeEvent (const QByteArray &eventType, void *message, long *result)
 
virtual void showEvent (QShowEvent *event)
 
virtual void tabletEvent (QTabletEvent *event)
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Protected Methods inherited from QPaintDevice
 QPaintDevice ()
 

Properties

 hasSelection
 
 icon
 
 modified
 
 renderHints
 
 selectedHtml
 
 selectedText
 
 textSizeMultiplier
 
 title
 
 url
 
 zoomFactor
 
- Properties inherited from QWidget
 acceptDrops
 
 accessibleDescription
 
 accessibleName
 
 autoFillBackground
 
 baseSize
 
 childrenRect
 
 childrenRegion
 
 contextMenuPolicy
 
 cursor
 
 enabled
 
 focus
 
 focusPolicy
 
 font
 
 frameGeometry
 
 frameSize
 
 fullScreen
 
 geometry
 
 height
 
 inputMethodHints
 
 isActiveWindow
 
 layoutDirection
 
 locale
 
 maximized
 
 maximumHeight
 
 maximumSize
 
 maximumWidth
 
 minimized
 
 minimumHeight
 
 minimumSize
 
 minimumSizeHint
 
 minimumWidth
 
 modal
 
 mouseTracking
 
 normalGeometry
 
 palette
 
 pos
 
 rect
 
 size
 
 sizeHint
 
 sizeIncrement
 
 sizePolicy
 
 statusTip
 
 styleSheet
 
 toolTip
 
 updatesEnabled
 
 visible
 
 whatsThis
 
 width
 
 windowFilePath
 
 windowFlags
 
 windowIcon
 
 windowIconText
 
 windowModality
 
 windowModified
 
 windowOpacity
 
 windowTitle
 
 x
 
 y
 
- Properties inherited from QObject
 objectName
 

Friends

class QWebPage
 

Additional Inherited Members

- Public Types inherited from QWidget
enum  RenderFlag
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric
 
- Static Public Methods inherited from QWidget
static QWidget * createWindowContainer (QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag)
 
static QWidget * find (WId id)
 
static QWidget * keyboardGrabber ()
 
static QWidget * mouseGrabber ()
 
static void setTabOrder (QWidget *firstWidget, QWidget *secondWidget)
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Slots inherited from QWidget
void updateMicroFocus ()
 

Detailed Description

The QWebView class provides a widget that is used to view and edit web documents. QWebView is the main widget component of the CsWebKit web browsing library. It can be used in various applications to display web content live from the Internet.

A web site can be loaded onto QWebView with the load() function. Like all CopperSpice widgets, the show() function must be invoked in order to display QWebView. The snippet below illustrates this:

QWebView *view = new QWebView(parent);
view->load(QUrl("https://www.copperspice.com"));
view->show();

Alternatively, setUrl() can also be used to load a web site. If you have the HTML content readily available, you can use setHtml() instead.

The loadStarted() signal is emitted when the view begins loading. The loadProgress() signal, on the other hand, is emitted whenever an element of the web view completes loading, such as an embedded image, a script, etc. Finally, the loadFinished() signal is emitted when the view has loaded completely. It's argument - either true or false - indicates load success or failure.

The page() function returns a pointer to the web page object. Refer to the "Elements of QWebView" for an explanation of how the web page is related to the view. To modify your web view's settings, you can access the QWebSettings object with the settings() function. With QWebSettings, you can change the default fonts, enable or disable features such as JavaScript and plugins.

The title of an HTML document can be accessed with the title() property. Additionally, a web site may also specify an icon, which can be accessed using the icon() property. If the title or the icon changes, the corresponding titleChanged() and iconChanged() signals will be emitted. The textSizeMultiplier() property can be used to change the overall size of the text displayed in the web view.

If you require a custom context menu, you can implement it by reimplementing contextMenuEvent() and populating your QMenu with the actions obtained from pageAction(). More functionality such as reloading the view, copying selected text to the clipboard, or pasting into the view, is also encapsulated within the QAction objects returned by pageAction(). These actions can be programmatically triggered using triggerPageAction(). Alternatively, the actions can be added to a toolbar or a menu directly. QWebView maintains the state of the returned actions but allows modification of action properties such as text or icon.

A QWebView can be printed onto a QPrinter using the print() function. This function is marked as a slot and can be conveniently connected to QPrintPreviewDialog's paintRequested() signal.

If you want to provide support for web sites that allow the user to open new windows, such as pop-up windows, you can subclass QWebView and reimplement the createWindow() function.

Elements of QWebView

QWebView consists of other objects such as QWebFrame and QWebPage. The flowchart below shows these elements are related.

Note
It is possible to use QWebPage and QWebFrame without using QWebView. Since CsWebKit depends on CsGui you must still use a QApplication instead of QCoreApplication.
See also
selectionChanged()

Constructor & Destructor Documentation

QWebView::QWebView ( QWidget parent = 0)
explicit

Constructs an empty QWebView with parent parent.

See also
load()
QWebView::~QWebView ( )
virtual

Destroys the web view.

Method Documentation

void QWebView::back ( )
slot

Convenience slot which will load the previous document in the list of documents built by navigating links. This method does nothing if there is no previous document.

This is equivalent to the following:

view->page()->triggerPageAction(QWebPage::GoBack);
See also
forward(), pageAction()
void QWebView::changeEvent ( QEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::changeEvent().

Reimplemented from QWidget.

void QWebView::contextMenuEvent ( QContextMenuEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::contextMenuEvent().

Reimplemented from QWidget.

QWebView * QWebView::createWindow ( QWebPage::WebWindowType  type)
protectedvirtual

This function is called from the createWindow() method of the associated QWebPage, each time the page wants to create a new window of the given type. This might be the result, for example, of a JavaScript request to open a document in a new window.

Note
If the createWindow() method of the associated page is reimplemented, this method is not called, unless explicitly done so in the reimplementation.
In the cases when the window creation is being triggered by JavaScript, apart from reimplementing this method application must also set the JavaScriptCanOpenWindows attribute of QWebSettings to true in order for it to get called.
See also
QWebPage::createWindow(), QWebPage::acceptNavigationRequest()
void QWebView::dragEnterEvent ( QDragEnterEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::dragEnterEvent().

Reimplemented from QWidget.

void QWebView::dragLeaveEvent ( QDragLeaveEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::dragLeaveEvent().

Reimplemented from QWidget.

void QWebView::dragMoveEvent ( QDragMoveEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::dragMoveEvent().

Reimplemented from QWidget.

void QWebView::dropEvent ( QDropEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::dropEvent().

Reimplemented from QWidget.

bool QWebView::event ( QEvent event)
override

Reimplemented from QObject::event().

bool QWebView::findText ( const QString subString,
QWebPage::FindFlags  options = 0 
)

Finds the specified subString, in the page using the given options. If the HighlightAllOccurrences flag is passed, the function will highlight all occurrences that exist in the page. All subsequent calls will extend the highlight, rather than replace it, with occurrences of the new string.

If the HighlightAllOccurrences flag is not passed, the function will select an occurrence and all subsequent calls will replace the current occurrence with the next one.

To clear the selection, just pass an empty string.

Returns true if subString was found, otherwise returns false.

See also
selectedText(), selectionChanged()
void QWebView::focusInEvent ( QFocusEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::focusInEvent().

Reimplemented from QWidget.

bool QWebView::focusNextPrevChild ( bool  next)
overrideprotectedvirtual

Reimplemented from QWidget::focusNextPrevChild().

Reimplemented from QWidget.

void QWebView::focusOutEvent ( QFocusEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::focusOutEvent().

Reimplemented from QWidget.

void QWebView::forward ( )
slot

Convenience slot that loads the next document in the list of documents built by navigating links. Does nothing if there is no next document.

It is equivalent to

view->page()->triggerPageAction(QWebPage::GoForward);
See also
back(), pageAction()
QWebHistory * QWebView::history ( ) const

Returns a pointer to the view's history of navigated web pages.

It is equivalent to

view->page()->history();
void QWebView::iconChanged ( )
signal

This signal is emitted whenever the icon of the page is loaded or changes.

In order for icons to be loaded, you will need to set an icon database path using QWebSettings::setIconDatabasePath().

See also
icon(), QWebSettings::setIconDatabasePath()
void QWebView::inputMethodEvent ( QInputMethodEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::inputMethodEvent().

Reimplemented from QWidget.

QVariant QWebView::inputMethodQuery ( Qt::InputMethodQuery  property) const
overridevirtual

Reimplemented from QWidget::inputMethodQuery().

Reimplemented from QWidget.

void QWebView::keyPressEvent ( QKeyEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::keyPressEvent().

Reimplemented from QWidget.

void QWebView::keyReleaseEvent ( QKeyEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::keyReleaseEvent().

Reimplemented from QWidget.

void QWebView::linkClicked ( const QUrl url)
signal

This signal is emitted whenever the user clicks on a link and the page's linkDelegationPolicy property is set to delegate the link handling for the specified url.

See also
QWebPage::linkDelegationPolicy()
void QWebView::load ( const QNetworkRequest request,
QNetworkAccessManager::Operation  operation = QNetworkAccessManager::GetOperation,
const QByteArray body = QByteArray() 
)

Loads a network request, request, using the method specified in operation.

body is optional and is only used for POST operations.

Note
The view remains the same until enough data has arrived to display the new url.
See also
url(), urlChanged()
void QWebView::load ( const QUrl url)

Loads the specified url and displays it.

Note
The view remains the same until enough data has arrived to display the new url.
See also
setUrl(), url(), urlChanged(), QUrl::fromUserInput()
void QWebView::loadFinished ( bool  ok)
signal

This signal is emitted when a load of the page is finished. ok will indicate whether the load was successful or any error occurred.

See also
loadStarted()
void QWebView::loadProgress ( int  progress)
signal

This signal is emitted every time an element in the web page completes loading and the overall loading progress advances.

This signal tracks the progress of all child frames.

The current value is provided by progress and scales from 0 to 100, which is the default range of QProgressBar.

See also
loadStarted(), loadFinished()
void QWebView::loadStarted ( )
signal

This signal is emitted when a new load of the page is started.

See also
loadProgress(), loadFinished()
void QWebView::mouseDoubleClickEvent ( QMouseEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::mouseDoubleClickEvent().

Reimplemented from QWidget.

void QWebView::mouseMoveEvent ( QMouseEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::mouseMoveEvent().

Reimplemented from QWidget.

void QWebView::mousePressEvent ( QMouseEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::mousePressEvent().

Reimplemented from QWidget.

void QWebView::mouseReleaseEvent ( QMouseEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::mouseReleaseEvent().

Reimplemented from QWidget.

QWebPage * QWebView::page ( ) const

Returns a pointer to the underlying web page.

See also
setPage()
QAction * QWebView::pageAction ( QWebPage::WebAction  action) const

Returns a pointer to a QAction that encapsulates the specified web action action.

void QWebView::paintEvent ( QPaintEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::paintEvent().

Reimplemented from QWidget.

void QWebView::reload ( )
slot

Reloads the current document.

See also
stop(), pageAction(), loadStarted()
void QWebView::resizeEvent ( QResizeEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::resizeEvent().

Reimplemented from QWidget.

void QWebView::selectionChanged ( )
signal

This signal is emitted whenever the selection changes.

See also
selectedText()
void QWebView::setContent ( const QByteArray data,
const QString mimeType = QString(),
const QUrl baseUrl = QUrl() 
)

Sets the content of the web view to the specified content data. If the mimeType argument is empty it is assumed the content is HTML.

External objects referenced in the content are located relative to baseUrl.

The data is loaded immediately; external objects are loaded asynchronously.

See also
load(), setHtml(), QWebFrame::toHtml()
void QWebView::setHtml ( const QString html,
const QUrl baseUrl = QUrl() 
)

Sets the content of the web view to the specified html.

External objects such as stylesheets or images referenced in the HTML document are located relative to baseUrl.

The html is loaded immediately; external objects are loaded asynchronously.

When using this method, WebKit assumes that external resources such as JavaScript programs or style sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external script can be specified through the charset attribute of the HTML script tag. Alternatively, the encoding can also be specified by the web server.

This is a convenience function equivalent to setContent(html, "text/html", baseUrl).

Warning
This function works only for HTML, for other mime types (i.e. XHTML, SVG) setContent() should be used instead.
See also
load(), setContent(), QWebFrame::toHtml(), QWebFrame::setContent()
void QWebView::setPage ( QWebPage page)

Makes page the new web page of the web view.

The parent QObject of the provided page remains the owner of the object. If the current page is a child of the web view, it will be deleted.

See also
page()
void QWebView::setRenderHint ( QPainter::RenderHint  hint,
bool  enabled = true 
)

If enabled is true, enables the specified render hint, otherwise disables it.

See also
renderHints, QPainter::renderHints()
void QWebView::setTextSizeMultiplier ( qreal  factor)

Sets the value of the multiplier used to scale the text in a Web page to the factor specified.

See also
textSizeMultiplier()
QWebSettings * QWebView::settings ( ) const

Returns a pointer to the view/page specific settings object.

It is equivalent to

view->page()->settings();
See also
QWebSettings::globalSettings()
QSize QWebView::sizeHint ( ) const
overridevirtual

Reimplemented from QWidget::sizeHint().

Reimplemented from QWidget.

void QWebView::statusBarMessage ( const QString text)
signal

This signal is emitted when the status bar text is changed by the page.

void QWebView::stop ( )
slot

Convenience slot that stops loading the document.

It is equivalent to

view->page()->triggerPageAction(QWebPage::Stop);
See also
reload(), pageAction(), loadFinished()
qreal QWebView::textSizeMultiplier ( ) const

Returns the value of the multiplier used to scale the text in a Web page.

See also
setTextSizeMultiplier()
void QWebView::titleChanged ( const QString title)
signal

This signal is emitted whenever the title of the main frame changes.

See also
title()
void QWebView::triggerPageAction ( QWebPage::WebAction  action,
bool  checked = false 
)

Triggers the specified action. If it is a checkable action the specified checked state is assumed.

The following example triggers the copy action and therefore copies any selected text to the clipboard.

view->triggerAction(QWebPage::Copy);
See also
pageAction()
void QWebView::urlChanged ( const QUrl url)
signal

This signal is emitted when the url of the view changes.

See also
url(), load()
void QWebView::wheelEvent ( QWheelEvent event)
overrideprotectedvirtual

Reimplemented from QWidget::wheelEvent().

Reimplemented from QWidget.

Property Documentation

QWebView::hasSelection

This property holds whether this page contains selected content or not.

By default, this property is false.

See also
selectionChanged()
PropertiesClass Methods
read hasSelection
QWebView::icon

This property holds the icon associated with the web page currently viewed.

By default, this property contains a null icon.

See also
iconChanged(), QWebSettings::iconForUrl()
PropertiesClass Methods
read icon
QWebView::modified

This property holds whether the document was modified by the user.

Parts of HTML documents can be editable for example through the contenteditable attribute on HTML elements.

By default, this property is false.

PropertiesClass Methods
read isModified
QWebView::renderHints

This property holds the default render hints for the view.

These hints are used to initialize QPainter before painting the Web page.

QPainter::TextAntialiasing and QPainter::SmoothPixmapTransform are enabled by default.

See also
QPainter::renderHints()
PropertiesClass Methods
read renderHints
write setRenderHints
QWebView::selectedHtml

This property holds the HTML currently selected.

By default, this property contains an empty string.

See also
findText(), selectionChanged(), selectedText()
PropertiesClass Methods
read selectedHtml
QWebView::selectedText

This property holds the text currently selected.

By default, this property contains an empty string.

See also
findText(), selectionChanged(), selectedHtml()
PropertiesClass Methods
read selectedText
QWebView::textSizeMultiplier
deprecated
Deprecated:
This property holds the scaling factor for all text in the frame.

Use setZoomFactor instead, in combination with the ZoomTextOnly attribute in QWebSettings.

Note
Setting this property also enables the ZoomTextOnly attribute in QWebSettings.

By default, this property contains a value of 1.0.

PropertiesClass Methods
read textSizeMultiplier
write setTextSizeMultiplier
designable true
QWebView::title

This property holds the title of the web page currently viewed.

By default, this property contains an empty string.

See also
titleChanged()
PropertiesClass Methods
read title
QWebView::url

This property holds the url of the web page currently viewed.

Setting this property clears the view and loads the URL.

By default, this property contains an empty, invalid URL.

See also
load(), urlChanged()
PropertiesClass Methods
read url
write setUrl
QWebView::zoomFactor

This property holds the zoom factor for the view.

PropertiesClass Methods
read zoomFactor
write setZoomFactor