Class: QgsLayoutItemHtml¶
-
class
qgis.core.
QgsLayoutItemHtml
(layout: QgsLayout)¶ Bases:
qgis._core.QgsLayoutMultiFrame
Constructor for QgsLayoutItemHtml, with the specified parent
layout
.Ownership is transferred to the layout.
A layout multiframe subclass for HTML content.
New in version 3.0: Enums
Methods
Returns the source mode for item’s HTML content.
Returns a new QgsLayoutItemHtml for the specified parent
layout
.Returns whether html item will evaluate QGIS expressions prior to rendering the HTML content.
Returns the HTML source displayed in the item if the item is using the QgsLayoutItemHtml.ManualHtml mode.
Reloads the html source from the url and redraws the item.
Returns the maximum distance allowed when calculating where to place page breaks in the html.
Recalculates the frame sizes for the current viewport dimensions
Sets the source
mode
for item’s HTML content.Sets whether the html item will evaluate QGIS expressions prior to rendering the HTML content.
Sets the
html
to display in the item when the item is using the QgsLayoutItemHtml.ManualHtml mode.Sets the maximum
distance
allowed when calculating where to place page breaks in the html.Sets the
url
for content to display in the item when the item is using the QgsLayoutItemHtml.Url mode.Sets whether the html item should use smart breaks.
Sets the user
stylesheet
CSS rules to use while rendering the HTML content.Sets whether user stylesheets are
enabled
for the HTML content.Returns the URL of the content displayed in the item if the item is using the QgsLayoutItemHtml.Url mode.
Returns whether html item is using smart breaks.
Returns the user stylesheet CSS rules used while rendering the HTML content.
Returns whether user stylesheets are enabled for the HTML content.
Signals
Attributes
-
class
ContentMode
¶ Bases:
int
-
ManualHtml
= 1¶
-
Url
= 0¶
-
childEvent
()¶
-
connectNotify
()¶
-
contentMode
(self) → QgsLayoutItemHtml.ContentMode¶ Returns the source mode for item’s HTML content.
See also
See also
See also
-
create
(layout: QgsLayout) → QgsLayoutItemHtml¶ Returns a new QgsLayoutItemHtml for the specified parent
layout
.
-
customEvent
()¶
-
disconnectNotify
()¶
-
displayName
(self) → str¶
-
evaluateExpressions
(self) → bool¶ Returns whether html item will evaluate QGIS expressions prior to rendering the HTML content. If set, any content inside [% %] tags will be treated as a QGIS expression and evaluated against the current atlas feature.
See also
-
findNearbyPageBreak
(self, yPos: float) → float¶
-
html
(self) → str¶ Returns the HTML source displayed in the item if the item is using the QgsLayoutItemHtml.ManualHtml mode.
See also
See also
-
icon
(self) → QIcon¶
-
isSignalConnected
()¶
-
loadHtml
(self, useCache: bool = False, context: QgsExpressionContext = None)¶ Reloads the html source from the url and redraws the item.
- Parameters
useCache – set to true to use a cached copy of remote html content
context – expression context for evaluating data defined urls and expressions in html
See also
See also
-
maxBreakDistance
(self) → float¶ Returns the maximum distance allowed when calculating where to place page breaks in the html. This distance is the maximum amount of empty space allowed at the bottom of a frame after calculating the optimum break location. This setting is only effective if useSmartBreaks is true.
See also
See also
-
readObjectPropertiesFromElement
()¶
-
readPropertiesFromElement
(self, itemElem: QDomElement, doc: QDomDocument, context: QgsReadWriteContext) → bool¶
-
recalculateFrameSizes
(self)¶ Recalculates the frame sizes for the current viewport dimensions
-
receivers
()¶
-
refreshDataDefinedProperty
(self, property: QgsLayoutObject.DataDefinedProperty = QgsLayoutObject.AllProperties)¶
-
render
(self, context: QgsLayoutItemRenderContext, renderExtent: QRectF, frameIndex: int)¶
-
sender
()¶
-
senderSignalIndex
()¶
-
setContentMode
(self, mode: QgsLayoutItemHtml.ContentMode)¶ Sets the source
mode
for item’s HTML content.See also
See also
See also
-
setEvaluateExpressions
(self, evaluateExpressions: bool)¶ Sets whether the html item will evaluate QGIS expressions prior to rendering the HTML content. If set, any content inside [% %] tags will be treated as a QGIS expression and evaluated against the current atlas feature.
See also
-
setHtml
(self, html: str)¶ Sets the
html
to display in the item when the item is using the QgsLayoutItemHtml.ManualHtml mode. Setting the HTML using this function does not automatically refresh the item’s contents. Call loadHtml to trigger a refresh of the item after setting the HTML content.See also
See also
See also
-
setMaxBreakDistance
(self, distance: float)¶ Sets the maximum
distance
allowed when calculating where to place page breaks in the html. This distance is the maximum amount of empty space allowed at the bottom of a frame after calculating the optimum break location. Setting a larger value will result in better choice of page break location, but more wasted space at the bottom of frames. This setting is only effective if useSmartBreaks is true.See also
See also
-
setUrl
(self, url: QUrl)¶ Sets the
url
for content to display in the item when the item is using the QgsLayoutItemHtml.Url mode. Content is automatically fetched and the HTML item refreshed after calling this function.See also
See also
-
setUseSmartBreaks
(self, useSmartBreaks: bool)¶ Sets whether the html item should use smart breaks. Smart breaks prevent the html frame contents from breaking mid-way though a line of text.
See also
-
setUserStylesheet
(self, stylesheet: str)¶ Sets the user
stylesheet
CSS rules to use while rendering the HTML content. These allow for overriding the styles specified within the HTML source. Setting the stylesheet using this function does not automatically refresh the item’s contents. Call loadHtml to trigger a refresh of the item after setting the stylesheet rules.See also
See also
See also
-
setUserStylesheetEnabled
(self, enabled: bool)¶ Sets whether user stylesheets are
enabled
for the HTML content.See also
See also
-
timerEvent
()¶
-
totalSize
(self) → QSizeF¶
-
type
(self) → int¶
-
url
(self) → QUrl¶ Returns the URL of the content displayed in the item if the item is using the QgsLayoutItemHtml.Url mode.
See also
See also
-
useSmartBreaks
(self) → bool¶ Returns whether html item is using smart breaks. Smart breaks prevent the html frame contents from breaking mid-way though a line of text.
See also
-
userStylesheet
(self) → str¶ Returns the user stylesheet CSS rules used while rendering the HTML content. These overriding the styles specified within the HTML source.
See also
See also
-
userStylesheetEnabled
(self) → bool¶ Returns whether user stylesheets are enabled for the HTML content.
See also
See also
-
writeObjectPropertiesToElement
()¶
-
writePropertiesToElement
(self, elem: QDomElement, doc: QDomDocument, context: QgsReadWriteContext) → bool¶
-
class