43 explicit QgsWebView( QWidget *parent =
nullptr )
44 : QTextBrowser( parent )
45 , mSettings( std::make_unique<QWebSettings>() )
46 , mPage( std::make_unique<QWebPage>(
this ) )
48 connect(
this, &QTextBrowser::anchorClicked,
this, &QgsWebView::linkClicked );
49 connect(
this, &QgsWebView::pageLoadFinished, mPage.get(), &QWebPage::loadFinished );
54 void setUrl(
const QUrl &url ) { setSource( url ); }
56 void load(
const QUrl &url ) { setSource( url ); }
58 QUrl url()
const {
return source(); }
60 QWebPage *page()
const {
return mPage.get(); }
62 QWebSettings *settings()
const {
return mSettings.get(); }
66 void setContent(
const QByteArray &data,
const QString &contentType,
const QUrl & )
68 QString text = QString::fromUtf8( data );
69 if ( contentType ==
"text/html" )
74 emit pageLoadFinished(
true );
77 void print( QPrinter * ) {}
80 void linkClicked(
const QUrl &link );
82 void pageLoadFinished(
bool ok );
86 void setHtml(
const QString &text )
88 QTextBrowser::setHtml( text );
89 emit pageLoadFinished(
true );
92 void setText(
const QString &text )
94 QTextBrowser::setText( text );
95 emit pageLoadFinished(
true );
99 std::unique_ptr<QWebSettings> mSettings;
100 std::unique_ptr<QWebPage> mPage;
A collection of stubs to mimic the API of a QWebPage on systems where QtWebkit is not available.