qwebviewglide默认缓存路径是不缓存的吗,如何给qwebview增加缓存

下次自动登录
现在的位置:
& 综合 & 正文
QWebview的sethtml和load中javasript的一些区别
呵呵,第一次写这样的总结文章...
由于总结是为了自己能懂的。所以,可能会大家看到有些地方是不清不楚的....见谅
sethtml是把页面代码打成一个字符串,再显示在QWebview中
load则是加载一个html文件
所以sethtml可以是一个非html文件,一段代码
而load则是加载一个html文件,网页
sethtml和load中的js代码对于系统资源的识别方面,也有差异,
sethtml没有默认的资源路径
load则有程序所在,路径的默认路径。
所以sethtml要加载系统资源,需要写如全路径,才能识别
而load则没有这么多要求。
&&&&推荐文章:
【上篇】【下篇】Qt 4.8: QWebView Class Reference
QWebView Class Reference
The QWebView class provides a widget that is used to view and edit web documents.
#include &QWebView&Inherits: .
This class was introduced in Qt 4.4.
Properties
: const bool
: const QIcon
: const bool
: QPainter::RenderHints
: const QString
: const QString
: const QString
58 properties inherited from
1 property inherited from
Public Functions
( QWidget * parent = 0 )
( const QString & subString, QWebPage::FindFlags options = 0 )
QWebHistory *
( const QUrl & url )
( const QNetworkRequest & request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray & body = QByteArray() )
QWebPage *
( QWebPage::WebAction action ) const
QPainter::RenderHints
( const QByteArray & data, const QString & mimeType = QString(), const QUrl & baseUrl = QUrl() )
( const QString & html, const QUrl & baseUrl = QUrl() )
( QWebPage * page )
( QPainter::RenderHint hint, bool enabled = true )
( QPainter::RenderHints hints )
( qreal factor )
( const QUrl & url )
( qreal factor )
QWebSettings *
( QWebPage::WebAction action, bool checked = false )
Reimplemented Public Functions
virtual bool
( QEvent * e )
virtual QVariant
( Qt::InputMethodQuery property ) const
virtual QSize
221 public functions inherited from
29 public functions inherited from
13 public functions inherited from
Public Slots
( QPrinter * printer ) const
19 public slots inherited from
1 public slot inherited from
( const QUrl & url )
( bool ok )
( int progress )
( const QString & text )
( const QString & title )
( const QUrl & url )
1 signal inherited from
1 signal inherited from
Protected Functions
virtual QWebView *
( QWebPage::WebWindowType type )
Reimplemented Protected Functions
virtual void
( QEvent * e )
virtual void
( QContextMenuEvent * ev )
virtual void
( QDragEnterEvent * ev )
virtual void
( QDragLeaveEvent * ev )
virtual void
( QDragMoveEvent * ev )
virtual void
( QDropEvent * ev )
virtual void
( QFocusEvent * ev )
virtual bool
( bool next )
virtual void
( QFocusEvent * ev )
virtual void
( QInputMethodEvent * e )
virtual void
( QKeyEvent * ev )
virtual void
( QKeyEvent * ev )
virtual void
( QMouseEvent * ev )
virtual void
( QMouseEvent * ev )
virtual void
( QMouseEvent * ev )
virtual void
( QMouseEvent * ev )
virtual void
( QPaintEvent * ev )
virtual void
( QResizeEvent * e )
virtual void
( QWheelEvent * ev )
37 protected functions inherited from
8 protected functions inherited from
1 protected function inherited from
Additional Inherited Members
4 static public members inherited from
7 static public members inherited from
1 protected slot inherited from
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
web browsing module. It can be used in various applications to display web content live from the Internet.
The image below shows QWebView previewed in Qt Designer with a Nokia website.
A web site can be loaded onto QWebView with the () function. Like all Qt widgets, the () function must be invoked in order to display QWebView. The snippet below illustrates this:
QWebView *view = new QWebView(parent);
view-&load((&/&));
view-&show();
Alternatively, () can also be used to load a web site. If you have the HTML content readily available, you can use () instead.
The () signal is emitted when the view begins loading. The () 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 () signal is emitted when the view has loaded completely. It's argument - either true or false - indicates load success or failure.
The () function returns a pointer to the web page object. See
for an explanation of how the web page is related to the view. To modify your web view's settings, you can access the
object with the () function. With , 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 () property. Additionally, a web site may also specify an icon, which can be accessed using the () property. If the title or the icon changes, the corresponding () and () signals will be emitted. The () 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
and populating your
with the actions obtained from (). More functionality such as reloading the view, copying selected text to the clipboard, or pasting into the view, is also encapsulated within the
objects returned by (). These actions can be programmatically triggered using (). 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
A QWebView can be printed onto a
using the () function. This function is marked as a slot and can be conveniently connected to 's
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 () function.
Elements of QWebView
QWebView consists of other objects such as
and . The flowchart below shows these elements are related.
Note: It is possible to use
and , without using QWebView, if you do not require
attributes. Nevertheless,
depends on , so you should use a
instead of .
See also , , , , and .
Property Documentation
hasSelection : const bool
This property holds whether this page contains selected content or not.
By default, this property is false.
Access functions:
bool hasSelection () const
See also ().
icon : const
This property holds the icon associated with the web page currently viewed.
By default, this property contains a null icon.
Access functions:
QIcon icon () const
See also () and ().
modified : const bool
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.
Access functions:
bool isModified () const
renderHints :
This property holds the default render hints for the view.
These hints are used to initialize
before painting the Web page.
are enabled by default.
Note: This property is not available on Symbian. However, the getter and setter functions can still be used directly.
This property was introduced in Qt 4.6.
Access functions:
QPainter::RenderHints renderHints () const
void setRenderHints ( QPainter::RenderHints hints )
See also ().
selectedHtml : const
This property holds the HTML currently selected.
By default, this property contains an empty string.
This property was introduced in Qt 4.8.
Access functions:
QString selectedHtml () const
See also (), (), and ().
selectedText : const
This property holds the text currently selected.
By default, this property contains an empty string.
Access functions:
QString selectedText () const
See also (), (), and ().
title : const
This property holds the title of the web page currently viewed.
By default, this property contains an empty string.
Access functions:
QString title () const
See also ().
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.
Access functions:
QUrl url () const
void setUrl ( const QUrl & url )
See also () and ().
zoomFactor :
This property holds the zoom factor for the view.
This property was introduced in Qt 4.5.
Access functions:
qreal zoomFactor () const
void setZoomFactor ( qreal factor )
Member Function Documentation
QWebView::QWebView (
* parent = 0 )
Constructs an empty
with parent parent.
See also ().
QWebView::~QWebView () [virtual]
Destroys the web view.
void QWebView::back () [slot]
Convenience slot that loads the previous document in the list of documents built by navigating links. Does nothing if there is no previous document.
It is equivalent to
view-&page()-&triggerPageAction(::GoBack);
See also () and ().
void QWebView::changeEvent (
* e ) [virtual protected]
Reimplemented from ().
void QWebView::contextMenuEvent (
* ev ) [virtual protected]
Reimplemented from ().
QWebView * QWebView::createWindow (
type ) [virtual protected]
This function is called from the createWindow() method of the associated , 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.
Note: 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
to true in order for it to get called.
See also () and ().
void QWebView::dragEnterEvent (
* ev ) [virtual protected]
Reimplemented from ().
void QWebView::dragLeaveEvent (
* ev ) [virtual protected]
Reimplemented from ().
void QWebView::dragMoveEvent (
* ev ) [virtual protected]
Reimplemented from ().
void QWebView::dropEvent (
* ev ) [virtual protected]
Reimplemented from ().
bool QWebView::event (
* e ) [virtual]
Reimplemented from ().
bool QWebView::findText ( const
& subString,
options = 0 )
Finds the specified string, 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 otherwise returns false.
See also () and ().
void QWebView::focusInEvent (
* ev ) [virtual protected]
Reimplemented from ().
bool QWebView::focusNextPrevChild ( bool next ) [virtual protected]
Reimplemented from ().
void QWebView::focusOutEvent (
* ev ) [virtual protected]
Reimplemented from ().
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(::GoForward);
See also () and ().
* 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 ().
See also () and ().
void QWebView::inputMethodEvent (
* e ) [virtual protected]
Reimplemented from ().
QWebView::inputMethodQuery (
property ) const [virtual]
Reimplemented from ().
void QWebView::keyPressEvent (
* ev ) [virtual protected]
Reimplemented from ().
void QWebView::keyReleaseEvent (
* ev ) [virtual protected]
Reimplemented from ().
void QWebView::linkClicked ( const
& 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 ().
void QWebView::load ( const
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 (), (), (), and ().
void QWebView::load ( const
& request,
operation = QNetworkAccessManager::GetOperation, const
& 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 () and ().
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 ().
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 .
See also () and ().
void QWebView::loadStarted () [signal]
This signal is emitted when a new load of the page is started.
See also () and ().
void QWebView::mouseDoubleClickEvent (
* ev ) [virtual protected]
Reimplemented from ().
void QWebView::mouseMoveEvent (
* ev ) [virtual protected]
Reimplemented from ().
void QWebView::mousePressEvent (
* ev ) [virtual protected]
Reimplemented from ().
void QWebView::mouseReleaseEvent (
* ev ) [virtual protected]
Reimplemented from ().
* QWebView::page () const
Returns a pointer to the underlying web page.
See also ().
* QWebView::pageAction (
action ) const
Returns a pointer to a
that encapsulates the specified web action action.
void QWebView::paintEvent (
* ev ) [virtual protected]
Reimplemented from ().
void QWebView::print (
* printer ) const [slot]
Prints the main frame to the given printer.
See also () and .
void QWebView::reload () [slot]
Reloads the current document.
See also (), (), and ().
void QWebView::resizeEvent (
* e ) [virtual protected]
Reimplemented from ().
void QWebView::selectionChanged () [signal]
This signal is emitted whenever the selection changes.
See also ().
void QWebView::setContent ( const
& data, const
& mimeType = QString(), const
& baseUrl = QUrl() )
Sets the content of the web view to the specified content data. If the mimeType argument is empty it is currently assumed that the content is HTML but in future versions we may introduce auto-detection.
External objects referenced in the content are located relative to baseUrl.
The data i external objects are loaded asynchronously.
See also (), (), and ().
void QWebView::setHtml ( const
& html, const
& 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 i 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) () should be used instead.
See also (), (), (), and ().
void QWebView::setPage (
Makes page the new web page of the web view.
The parent
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 ().
void QWebView::setRenderHint (
hint, bool enabled = true )
If enabled is true, enables the specified render hint; otherwise disables it.
This function was introduced in Qt 4.6.
void QWebView::setTextSizeMultiplier (
Sets the value of the multiplier used to scale the text in a Web page to the factor specified.
See also ().
* QWebView::settings () const
Returns a pointer to the view/page specific settings object.
It is equivalent to
view-&page()-&settings();
See also ().
QWebView::sizeHint () const [virtual]
Reimplemented from ().
void QWebView::statusBarMessage ( const
& 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(::Stop);
See also (), (), and ().
QWebView::textSizeMultiplier () const
Returns the value of the multiplier used to scale the text in a Web page.
See also ().
void QWebView::titleChanged ( const
& title ) [signal]
This signal is emitted whenever the title of the main frame changes.
See also ().
void QWebView::triggerPageAction (
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(::Copy);
See also ().
void QWebView::urlChanged ( const
& url ) [signal]
This signal is emitted when the url of the view changes.
See also () and ().
void QWebView::wheelEvent (
* ev ) [virtual protected]
Reimplemented from ().当前位置: →
→ QWidget能否转化成QWebview该怎么解决
QWidget能否转化成QWebview该怎么解决
& 作者:佚名 & 来源: 互联网 & 热度:
&收藏到→_→:
摘要: QWidget能否转化成QWebview?QTabWidget中addTab()方法,将一个QWidget对象加到选项卡中。现在想将QWidget控件以QWebview的方...
"QWidget能否转化成QWebview该怎么解决"::
qwidget能否转化成qwebview?qtabwidget中addtab()方法,将一个qwidget对象加到选项卡中。现在想将qwidget控件以qwebview的方式放入选项卡,怎么解决啊?(ps:强制类型转化或者qwebview *webview = qobject_cast&qwebview*&(widget); 的方法都行不通啊,强制转换过来的qwebview对象是空的,不知道怎么回事?求大神指导)------解决方案--------------------当然不行,一个qwidget怎么能转化为qwebview呢
------解决方案--------------------本身是qwebview或者其子类才能转换比如你的qwebview插入到stackedwidget中,然后通过currentindex拿到的是一个qwidget指针这时候你可以用(qwebview*)去强制转换这个指针得到对应页面上的qwebview
------解决方案--------------------qwebview 继承自 qwidget,所以,可以使用 类型转换. 搜索此文相关文章:此文来自: 马开东博客
网址: 站长QQ
上一篇:没有了
QWidget能否转化成QWebview该怎么解决_QT开发相关文章
QT开发_总排行榜
QT开发_最新
QT开发_月排行榜
QT开发_周排行榜
QT开发_日排行榜Qt 5.3 使用原来的QT4.8.4项目时QWebView 、QWebFrame等类无法编译通过。
出现原因:QWebView 、QWebFrame、QWebPage、QWebInspector等这些类被单独移到了QtWebKitWidgets模块,不再在QtWebKit模块当中;而QWebHistory等类仍然保留在QtWebkit模块中。
解决方法:使用到QWebPage等webkit相关可视部件的,Qt5.3单独放到了QtWebKitWidgets模块中,所以在使用了QWebPage类的地方:
(1)在*.pro中要加QT&+=&webkitwidgets
(2)你所创建的工程默认搜索路径是Qt的Include根目录,在该目录下看不到 &QWebView&,所以#include &QtWebKitWidgets/QWebView&,可以找到相应地文件,但出现无法解析的外部符号,表明没有找到相应的连接库,可以手动将库加到工程里,如果是MSVC编译器,可以这样:
在*.cpp中加头文件:
#include &QtWebKitWidgets/QWebView&
#pragma comment(lib,&Qt5Widgets.lib&)
#pragma comment(lib,&Qt5WebKitWidgets.lib&)
#include &mainwindow.h&
#include &QApplication&
#include&QtWebKitWidgets/QWebView&
int main(int argc, char *argv[])
QApplication a(argc, argv);
QWebView* view = new QWebV
view-&load(QUrl(&qrc:/html/index4.html&));
view-&show();
return a.exec();
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:98784次
积分:2156
积分:2156
排名:第17536名
原创:107篇
转载:93篇
(1)(1)(25)(18)(3)(2)(13)(4)(1)(2)(4)(6)(6)(1)(1)(10)(8)(1)(1)(1)(2)(1)(3)(2)(4)(4)(2)(6)(9)(11)(14)(21)(2)(1)(1)(8)1218人阅读
QT C++(86)
项目中遇到一个问题,直接打印html网页模版出现一些不清晰的情况,将网页转成图片再打印就清楚了。也可以将html网页转成图片格式保存在本地。
直接上代码:
QPrinter m_
QString printerName = m_printer.printerName();
if( printerName.size() == 0){
ChMessageOnlyOk_Information("找不到打印机!");
//直接打网页
m_printWebView-&print(&m_printer);
//把web网页转成painter图片打印
QPainter painter(&m_printer);
m_printWebView-&page()-&mainFrame()-&render(&painter);
painter.end();
//这里也可以把web网页转成painter变成一张图片保存下来
QImage *img = new QImage(500,500,QImage::Format_RGB32);
QPainter painter(img);
m_printWebView-&page()-&mainFrame()-&render(&painter);
painter.end();
img-&save("D:/img.jpg");
m_printer.setPageSize(QPagedPaintDevice::Custom);
m_printer.setPageSizeMM(QSize(10.1, 8.2));
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:536087次
积分:6638
积分:6638
排名:第3541名
原创:161篇
转载:32篇
评论:219条
(2)(5)(4)(3)(2)(7)(2)(10)(10)(4)(7)(3)(1)(4)(3)(4)(3)(1)(8)(4)(9)(5)(8)(5)(5)(5)(3)(3)(1)(1)(1)(2)(3)(1)(1)(2)(1)(12)(6)(4)(10)(1)(22)}

我要回帖

更多关于 网易云默认缓存目录 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信