Qt WebKit学习笔记(4)---实战QWebView--2

关于QWebView的信号与槽,下面列出:

Public Slots

  • void back ()
  • void forward ()
  • void print ( QPrinter * printer ) const
  • void reload ()
  • void stop ()
  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject
  • void iconChanged ()
  • void linkClicked ( const QUrl & url )
  • 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 & url )
  • 1 signal inherited from QWidget
  • 1 signal inherited from QObject

Signals

1.loadStarted、loadFinished和loadProgress信号介绍

loadStarted信号当有新的web page请求时发出。而我们关注更多的是loadProgress信号。loadProgress信号在load web page的一个元素成功时发出。这里的元素指代image、text、script对象。loadProgress的value表明了网页load的进度,范围从0-100。我们可以看出,QWebView封装了获得load进度值的计算方法。我们可以连接信号,对进度条赋值
connect(webView, SIGNAL(loadProgress(int)), SLOT(setProgress(int)));
其中setProgress方法需要自己定义。
loadFinished信号在web page load完成后发送。

2.iconChanged、selectionChanged、titleChanged和urlChanged信号介绍

当web page显示网页的icon、selected text、title或url改变时发送

3.back、forward、reload、print、stop槽介绍

back、forward对应QWebPage的后退与前进操作,相当于webView->page()->triggerPageAction(QWebPage::Back);和
webView->page()->triggerPageAction(QWebPage::Forward);
其中QWebView通过调用page方法返回current page. QWebPage::Back和QWebPage::Forward在QWebPage::WebAction中定义
 
Reload与stop槽为重载与停止load web page
 
Print槽用于将main frame通过QPrinter paints出来。这里可以更进一步了解QWebView、QWebPage与QWebFrame三者的层次结构

4.linkClicked与statusBarMessage信号

首先,linkClicked信号能够发送的前提是对应的QWebPage::linkDelegationPolicy被设定为允许链接
而statusBarMessage信号发生在status text改变时
 
原文地址:https://www.cnblogs.com/MingZznet/p/3225328.html