QGIS API Documentation 3.99.0-Master (21b3aa880ba)
Loading...
Searching...
No Matches
qgswebenginepage.h
Go to the documentation of this file.
1/***************************************************************************
2 qgswebenginepage.h
3 -------------------
4 begin : December 2023
5 copyright : (C) 2023 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSWEBENGINEPAGE_H
19#define QGSWEBENGINEPAGE_H
20
21#include <memory>
22
23#include "qgis_core.h"
24#include "qgis_sip.h"
25
26#include <QObject>
27#include <QPageLayout>
28#include <QSize>
29#include <QUrl>
30
31SIP_IF_MODULE( HAVE_WEBENGINE_SIP )
32
33class QWebEnginePage;
34class QPainter;
35
44class CORE_EXPORT QgsWebEnginePage : public QObject
45{
46 Q_OBJECT
47
48 public:
49
53 QgsWebEnginePage( QObject *parent SIP_TRANSFERTHIS = nullptr );
55
61 QWebEnginePage *page() SIP_SKIP;
62
74 bool setContent( const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl(), bool blocking = false );
75
89 bool setHtml( const QString &html, const QUrl &baseUrl = QUrl(), bool blocking = false );
90
102 bool setUrl( const QUrl &url, bool blocking = false );
103
109 QSize documentSize() const;
110
123 bool render( QPainter *painter, const QRectF &painterRect ) SIP_THROW( QgsNotSupportedException );
124
125 signals:
126
131
138 void loadProgress( int progress );
139
147 void loadFinished( bool ok );
148
149 private:
150
151 void handlePostBlockingLoadOperations();
152
153 std::unique_ptr< QWebEnginePage > mPage;
154 mutable QSize mCachedSize;
155};
156
157#endif // QGSWEBENGINEPAGE_H
Custom exception class which is raised when an operation is not supported.
bool setContent(const QByteArray &data, const QString &mimeType=QString(), const QUrl &baseUrl=QUrl(), bool blocking=false)
Sets the content of the web page to data.
void loadStarted()
This signal is emitted when the page starts loading content.
bool setHtml(const QString &html, const QUrl &baseUrl=QUrl(), bool blocking=false)
Sets the content of this page to html.
bool setUrl(const QUrl &url, bool blocking=false)
Sets the url of the web page to be displayed.
void loadFinished(bool ok)
This signal is emitted when the page finishes loading content.
QgsWebEnginePage(QObject *parent=nullptr)
Constructor for QgsWebEnginePage, with the specified parent widget.
bool render(QPainter *painter, const QRectF &painterRect)
Renders the web page contents to a painter.
void loadProgress(int progress)
This signal is emitted when the global progress status changes.
~QgsWebEnginePage() override
QWebEnginePage * page()
Returns a reference to the QWebEnginePage.
QSize documentSize() const
Returns the size of the page document, in pixels.
#define SIP_IF_MODULE(condition)
Definition qgis_sip.h:28
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_THROW(name,...)
Definition qgis_sip.h:211