QWebFrame Class ReferenceThe QWebFrame class represents a frame in a web page. More... #include <QWebFrame> Inherits QObject. This class was introduced in Qt 4.4. Public Types
Properties
Public Functions
Reimplemented Public Functions
Public Slots
Signals
Additional Inherited MembersDetailed DescriptionThe QWebFrame class represents a frame in a web page. QWebFrame represents a frame inside a web page. Each QWebPage object contains at least one frame, the main frame, obtained using QWebPage::mainFrame(). Additional frames will be created for HTML <frame> or <iframe> elements. A frame can be loaded using load() or setUrl(). Alternatively, if you have the HTML content readily available, you can use setHtml() instead. The page() function returns a pointer to the web page object. See Elements of QWebView for an explanation of how web frames are related to a web page and web view. The QWebFrame class also offers methods to retrieve both the URL currently loaded by the frame (see url()) as well as the URL originally requested to be loaded (see requestedUrl()). These methods make possible the retrieval of the URL before and after a DNS resolution or a redirection occurs during the load process. The requestedUrl() also matches to the URL added to the frame history (QWebHistory) if load is successful. The title of an HTML frame can be accessed with the title() property. Additionally, a frame 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 zoomFactor() property can be used to change the overall size of the content displayed in the frame. QWebFrame objects are created and controlled by the web page. You can connect to the web page's frameCreated() signal to be notified when a new frame is created. There are multiple ways to programmatically examine the contents of a frame. The hitTestContent() function can be used to find elements by coordinate. For access to the underlying DOM tree, there is documentElement(), findAllElements() and findFirstElement(). A QWebFrame 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. See also QWebPage. Member Type Documentationenum QWebFrame::RenderLayerThis enum describes the layers available for rendering using render(). The layers can be OR-ed together from the following list:
Property DocumentationbaseUrl : const QUrlThis property holds the base URL of the frame, can be used to resolve relative URLs. This property was introduced in Qt 4.6. Access functions:
contentsSize : const QSizeThis property holds the size of the contents in this frame. Access functions:
See also contentsSizeChanged(). focus : const boolReturns true if this frame has keyboard input focus; otherwise, returns false. This property was introduced in Qt 4.6. Access functions:
icon : const QIconThis property holds the icon associated with this frame. Access functions:
See also iconChanged() and QWebSettings::iconForUrl(). requestedUrl : const QUrlThe URL requested to loaded by the frame currently viewed. The URL may differ from the one returned by url() if a DNS resolution or a redirection occurs. This property was introduced in Qt 4.6. Access functions:
scrollPosition : QPointThis property holds the position the frame is currently scrolled to. This property was introduced in Qt 4.5. Access functions:
title : const QStringThis property holds the title of the frame as defined by the HTML <title> element. Access functions:
See also titleChanged(). url : QUrlThis property holds the url of the frame currently viewed. Setting this property clears the view and loads the URL. By default, this property contains an empty, invalid URL. Access functions:
See also urlChanged(). zoomFactor : qrealThis property holds the zoom factor for the frame. This property was introduced in Qt 4.5. Access functions:
Member Function Documentationvoid QWebFrame::addToJavaScriptWindowObject ( const QString & name, QObject * object )Make object available under name from within the frame's JavaScript context. The object will be inserted as a child of the frame's window object. Qt properties will be exposed as JavaScript properties and slots as JavaScript methods. If you want to ensure that your QObjects remain accessible after loading a new URL, you should add them in a slot connected to the javaScriptWindowObjectCleared() signal. If Javascript is not enabled for this page, then this method does nothing. The object will never be explicitly deleted by QtWebKit. void QWebFrame::addToJavaScriptWindowObject ( const QString & name, QObject * object, QScriptEngine::ValueOwnership own )This is an overloaded function. Make object available under name from within the frame's JavaScript context. The object will be inserted as a child of the frame's window object. Qt properties will be exposed as JavaScript properties and slots as JavaScript methods. If you want to ensure that your QObjects remain accessible after loading a new URL, you should add them in a slot connected to the javaScriptWindowObjectCleared() signal. If Javascript is not enabled for this page, then this method does nothing. The ownership of object is specified using own. QList<QWebFrame *> QWebFrame::childFrames () constReturns a list of all frames that are direct children of this frame. See also parentFrame(). void QWebFrame::contentsSizeChanged ( const QSize & size ) [signal]This signal is emitted when the frame's contents size changes to size. This function was introduced in Qt 4.6. See also contentsSize(). QWebElement QWebFrame::documentElement () constReturns the document element of this frame. The document element provides access to the entire structured content of the frame. This function was introduced in Qt 4.6. QVariant QWebFrame::evaluateJavaScript ( const QString & scriptSource ) [slot]Evaluates the JavaScript defined by scriptSource using this frame as context and returns the result of the last executed statement. See also addToJavaScriptWindowObject() and javaScriptWindowObjectCleared(). bool QWebFrame::event ( QEvent * e ) [virtual]Reimplemented from QObject::event(). QWebElementCollection QWebFrame::findAllElements ( const QString & selectorQuery ) constReturns a new list of elements matching the given CSS selector selectorQuery. If there are no matching elements, an empty list is returned. Standard CSS2 selector syntax is used for the query. This function was introduced in Qt 4.6. See also QWebElement::findAll(). QWebElement QWebFrame::findFirstElement ( const QString & selectorQuery ) constReturns the first element in the frame's document that matches the given CSS selector selectorQuery. If there is no matching element, a null element is returned. Standard CSS2 selector syntax is used for the query. This function was introduced in Qt 4.6. See also QWebElement::findFirst(). QString QWebFrame::frameName () constThe name of this frame as defined by the parent frame. QRect QWebFrame::geometry () constReturn the geometry of the frame relative to it's parent frame. QWebHitTestResult QWebFrame::hitTestContent ( const QPoint & pos ) constPerforms a hit test on the frame contents at the given position pos and returns the hit test result. void QWebFrame::iconChanged () [signal]This signal is emitted when the icon ("favicon") associated with the frame has been loaded. See also icon(). void QWebFrame::initialLayoutCompleted () [signal]This signal is emitted when the frame is laid out the first time. This is the first time you will see contents displayed on the frame. Note: A frame can be laid out multiple times. void QWebFrame::javaScriptWindowObjectCleared () [signal]This signal is emitted whenever the global window object of the JavaScript environment is cleared, e.g., before starting a new load. If you intend to add QObjects to a QWebFrame using addToJavaScriptWindowObject(), you should add them in a slot connected to this signal. This ensures that your objects remain accessible when loading new URLs. void QWebFrame::load ( const QUrl & url )Loads url into this frame. Note: The view remains the same until enough data has arrived to display the new url. See also setUrl(), setHtml(), and setContent(). void QWebFrame::load ( const QNetworkRequest & req, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray & body = QByteArray() )Loads a network request, req, into this frame, 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 content. See also setUrl(). void QWebFrame::loadFinished ( bool ok ) [signal]This signal is emitted when a load of this frame is finished. ok will indicate whether the load was successful or any error occurred. This function was introduced in Qt 4.6. See also loadStarted(). void QWebFrame::loadStarted () [signal]This signal is emitted when a new load of this frame is started. This function was introduced in Qt 4.6. See also loadFinished(). QMultiMap<QString, QString> QWebFrame::metaData () constReturns the meta data in this frame as a QMultiMap The meta data consists of the name and content attributes of the of the <meta> tags in the HTML document. For example: <html> <head> <meta name="description" content="This document is a tutorial about Qt development"> <meta name="keywords" content="Qt, WebKit, Programming"> </head> ... </html> Given the above HTML code the metaData() function will return a map with two entries:
This function returns a multi map to support multiple meta tags with the same attribute name. This function was introduced in Qt 4.5. QWebPage * QWebFrame::page () constThe web page that contains this frame. void QWebFrame::pageChanged () [signal]QWebFrame * QWebFrame::parentFrame () constReturns the parent frame of this frame, or 0 if the frame is the web pages main frame. This is equivalent to qobject_cast<QWebFrame*>(frame->parent()). See also childFrames(). QPoint QWebFrame::pos () constReturns the position of the frame relative to it's parent frame. void QWebFrame::print ( QPrinter * printer ) const [slot]Prints the frame to the given printer. See also render(). void QWebFrame::render ( QPainter * painter )Render the frame into painter. void QWebFrame::render ( QPainter * painter, const QRegion & clip )Render the frame into painter clipping to clip. void QWebFrame::render ( QPainter * painter, RenderLayer layer, const QRegion & clip = QRegion() )Render the layer of the frame using painter clipping to clip. This function was introduced in Qt 4.6. See also print(). QString QWebFrame::renderTreeDump () constReturns a dump of the rendering tree. This is mainly useful for debugging html. void QWebFrame::scroll ( int dx, int dy )Scrolls the frame dx pixels to the right and dy pixels downward. Both dx and dy may be negative. This function was introduced in Qt 4.5. See also QWebFrame::scrollPosition. QRect QWebFrame::scrollBarGeometry ( Qt::Orientation orientation ) constReturns the geometry for the scrollbar with orientation orientation. If the scrollbar does not exist an empty rect is returned. This function was introduced in Qt 4.6. int QWebFrame::scrollBarMaximum ( Qt::Orientation orientation ) constReturns the maximum value for the scrollbar with orientation orientation, or 0 if no scrollbar is found for orientation. See also scrollBarMinimum(). int QWebFrame::scrollBarMinimum ( Qt::Orientation orientation ) constReturns the minimum value for the scrollbar with orientation orientation. The minimum value is always 0. See also scrollBarMaximum(). Qt::ScrollBarPolicy QWebFrame::scrollBarPolicy ( Qt::Orientation orientation ) constReturns the scrollbar policy for the scrollbar defined by orientation. See also setScrollBarPolicy(). int QWebFrame::scrollBarValue ( Qt::Orientation orientation ) constReturns the current value for the scrollbar with orientation orientation, or 0 if no scrollbar is found for orientation. See also setScrollBarValue(), scrollBarMinimum(), and scrollBarMaximum(). void QWebFrame::scrollToAnchor ( const QString & anchor )Scrolls the frame to the given anchor name. This function was introduced in Qt 4.7. QWebSecurityOrigin QWebFrame::securityOrigin () constReturns the frame's security origin. This function was introduced in Qt 4.5. void QWebFrame::setContent ( const QByteArray & data, const QString & mimeType = QString(), const QUrl & baseUrl = QUrl() )Sets the content of this frame 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 is loaded immediately; external objects are loaded asynchronously. Note: This method will not affect session or global history for the frame. See also toHtml() and setHtml(). void QWebFrame::setFocus ()Gives keyboard input focus to this frame. This function was introduced in Qt 4.6. See also hasFocus(). void QWebFrame::setHtml ( const QString & html, const QUrl & baseUrl = QUrl() )Sets the content of this frame to html. baseUrl is optional and used to resolve relative URLs in the document, such as referenced images or stylesheets. The html is loaded immediately; external objects are loaded asynchronously. If a script in the html runs longer than the default script timeout (currently 10 seconds), for example due to being blocked by a modal JavaScript alert dialog, this method will return as soon as possible after the timeout and any subsequent html will be 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. It is also possible for the encoding to be specified by web server. Note: This method will not affect session or global history for the frame. See also toHtml() and setContent(). void QWebFrame::setScrollBarPolicy ( Qt::Orientation orientation, Qt::ScrollBarPolicy policy )Sets the scrollbar policy for the scrollbar defined by orientation to policy. See also scrollBarPolicy(). void QWebFrame::setScrollBarValue ( Qt::Orientation orientation, int value )Sets the current value for the scrollbar with orientation orientation. The scrollbar forces the value to be within the legal range: minimum <= value <= maximum. Changing the value also updates the thumb position. See also scrollBarValue(), scrollBarMinimum(), and scrollBarMaximum(). void QWebFrame::setTextSizeMultiplier ( qreal factor )Sets the value of the multiplier used to scale the text in a Web frame to the factor specified. See also textSizeMultiplier(). qreal QWebFrame::textSizeMultiplier () constReturns the value of the multiplier used to scale the text in a Web frame. See also setTextSizeMultiplier(). void QWebFrame::titleChanged ( const QString & title ) [signal]This signal is emitted whenever the title of the frame changes. The title string specifies the new title. See also title(). QString QWebFrame::toHtml () constReturns the frame's content as HTML, enclosed in HTML and BODY tags. See also setHtml() and toPlainText(). QString QWebFrame::toPlainText () constReturns the content of this frame converted to plain text, completely stripped of all HTML formatting. See also toHtml(). void QWebFrame::urlChanged ( const QUrl & url ) [signal]This signal is emitted with the URL of the frame when the frame's title is received. The new URL is specified by url. See also url(). X
|
Попытка перевода Qt документации. Если есть желание присоединиться, или если есть замечания или пожелания, то заходите на форум: Перевод Qt документации на русский язык... Люди внесшие вклад в перевод: Команда переводчиков |