Slicer  5.1
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
List of all members | Public Types | Properties | Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Friends
qSlicerWebWidget Class Reference

#include <Base/QTGUI/qSlicerWebWidget.h>

Inheritance diagram for qSlicerWebWidget:
Inheritance graph
Collaboration diagram for qSlicerWebWidget:
Collaboration graph

Public Types

typedef QWidget Superclass
 Superclass typedef. More...


bool handleExternalUrlWithDesktopService
QStringList internalHosts
bool javaScriptConsoleMessageLoggingEnabled
QString url

Public Slots

void onDownloadFinished (QNetworkReply *reply)
void onDownloadProgress (qint64 bytesReceived, qint64 bytesTotal)
void onDownloadStarted (QNetworkReply *reply)
void setUrl (const QString &url)
 Convenience for setting the internal webView QUrl from a QString. More...
void printToPdf (const QString &filePath)
void printToPdf (const QString &filePath, const QPageLayout &pageLayout)


void evalResult (QString js, QString result)
 emitted with result of evalJS More...
void loadFinished (bool ok)
void loadProgress (int progress)
void loadStarted ()
 signal passed through from QWebEngineView More...
void pdfPrintingFinished (const QString &filePath, bool success)
 signal passed through from QWebEnginePage More...

Public Member Functions

Q_INVOKABLE QString evalJS (const QString &js)
bool handleExternalUrlWithDesktopService () const
 Return true if external URL should be open with desktop service. More...
QStringList internalHosts () const
 Set/Get internal host. More...
bool javaScriptConsoleMessageLoggingEnabled () const
 Return true if javascript console messages should be logged. More...
 qSlicerWebWidget (QWidget *parent=nullptr)
 Constructor. More...
void setHandleExternalUrlWithDesktopService (bool enable)
Q_INVOKABLE void setHtml (const QString &html, const QUrl &baseUrl=QUrl())
 Convenience for setting the internal webView html from a QString. More...
void setInternalHosts (const QStringList &hosts)
void setJavaScriptConsoleMessageLoggingEnabled (bool enable)
Q_INVOKABLE QString url ()
 Convenience for setting the internal webView QUrl from a QString. More...
Q_INVOKABLE QWebEngineView * webView ()
 Return a reference to the QWebView used internally. More...
 ~qSlicerWebWidget () override
 Destructor. More...

Protected Slots

void handleSslErrors (QNetworkReply *reply, const QList< QSslError > &errors)
virtual void initJavascript ()
virtual void onLoadFinished (bool ok)
virtual void onLoadProgress (int progress)
virtual void onLoadStarted ()

Protected Member Functions

virtual bool acceptNavigationRequest (const QUrl &url, QWebEnginePage::NavigationType type, bool isMainFrame)
bool eventFilter (QObject *obj, QEvent *event) override
 qSlicerWebWidget (qSlicerWebWidgetPrivate *pimpl, QWidget *parent=nullptr)

Protected Attributes

QScopedPointer< qSlicerWebWidgetPrivate > d_ptr


class qSlicerWebEnginePage

Detailed Description

Definition at line 44 of file qSlicerWebWidget.h.

Member Typedef Documentation

◆ Superclass

Superclass typedef.

Definition at line 55 of file qSlicerWebWidget.h.

Property Documentation

◆ handleExternalUrlWithDesktopService

bool qSlicerWebWidget::handleExternalUrlWithDesktopService

Definition at line 48 of file qSlicerWebWidget.h.

◆ internalHosts

QStringList qSlicerWebWidget::internalHosts

Definition at line 49 of file qSlicerWebWidget.h.

◆ javaScriptConsoleMessageLoggingEnabled

bool qSlicerWebWidget::javaScriptConsoleMessageLoggingEnabled

Definition at line 50 of file qSlicerWebWidget.h.

◆ url

QString qSlicerWebWidget::url

Definition at line 51 of file qSlicerWebWidget.h.

Constructor & Destructor Documentation

◆ qSlicerWebWidget() [1/2]

qSlicerWebWidget::qSlicerWebWidget ( QWidget *  parent = nullptr)


◆ ~qSlicerWebWidget()

qSlicerWebWidget::~qSlicerWebWidget ( )


◆ qSlicerWebWidget() [2/2]

qSlicerWebWidget::qSlicerWebWidget ( qSlicerWebWidgetPrivate *  pimpl,
QWidget *  parent = nullptr 

Member Function Documentation

◆ acceptNavigationRequest()

virtual bool qSlicerWebWidget::acceptNavigationRequest ( const QUrl &  url,
QWebEnginePage::NavigationType  type,
bool  isMainFrame 

Reimplemented in qSlicerExtensionsServerWidget.

◆ evalJS()

Q_INVOKABLE QString qSlicerWebWidget::evalJS ( const QString &  js)

Convenient function to evaluate JS in main frame context from C++ or Python code

◆ evalResult

void qSlicerWebWidget::evalResult ( QString  js,
QString  result 

emitted with result of evalJS

◆ eventFilter()

bool qSlicerWebWidget::eventFilter ( QObject *  obj,
QEvent *  event 

Event filter used to capture WebView Show and Hide events in order to both set "document.webkitHidden" property and trigger the associated event.

◆ handleExternalUrlWithDesktopService()

bool qSlicerWebWidget::handleExternalUrlWithDesktopService ( ) const

Return true if external URL should be open with desktop service.

Setting both this property to true and at least one internal host will ensure URLs not matching an internal host are open with the current desktop browser.

See also
setInternalHost(const QString&)

◆ handleSslErrors

void qSlicerWebWidget::handleSslErrors ( QNetworkReply *  reply,
const QList< QSslError > &  errors 

◆ initJavascript

virtual void qSlicerWebWidget::initJavascript ( )

◆ internalHosts()

QStringList qSlicerWebWidget::internalHosts ( ) const

Set/Get internal host.

See also

◆ javaScriptConsoleMessageLoggingEnabled()

bool qSlicerWebWidget::javaScriptConsoleMessageLoggingEnabled ( ) const

Return true if javascript console messages should be logged.

Default value initialized based on the "Developer/DeveloperMode" setting.

See also

◆ loadFinished

void qSlicerWebWidget::loadFinished ( bool  ok)

◆ loadProgress

void qSlicerWebWidget::loadProgress ( int  progress)

◆ loadStarted

void qSlicerWebWidget::loadStarted ( )

signal passed through from QWebEngineView

◆ onDownloadFinished

void qSlicerWebWidget::onDownloadFinished ( QNetworkReply *  reply)

◆ onDownloadProgress

void qSlicerWebWidget::onDownloadProgress ( qint64  bytesReceived,
qint64  bytesTotal 

◆ onDownloadStarted

void qSlicerWebWidget::onDownloadStarted ( QNetworkReply *  reply)

◆ onLoadFinished

virtual void qSlicerWebWidget::onLoadFinished ( bool  ok)

◆ onLoadProgress

virtual void qSlicerWebWidget::onLoadProgress ( int  progress)

◆ onLoadStarted

virtual void qSlicerWebWidget::onLoadStarted ( )

◆ pdfPrintingFinished

void qSlicerWebWidget::pdfPrintingFinished ( const QString &  filePath,
bool  success 

signal passed through from QWebEnginePage

◆ printToPdf [1/2]

void qSlicerWebWidget::printToPdf ( const QString &  filePath)

Renders the current content of the page into a PDF document and saves it in the location specified in filePath.

The page size and orientation of the produced PDF document are taken from the values specified in pageLayout. This method issues an asynchronous request for printing the web page into a PDF and returns immediately. To be informed about the result of the request, connect to the signal pdfPrintingFinished().

If a file already exists at the provided file path, it will be overwritten.

See also

◆ printToPdf [2/2]

void qSlicerWebWidget::printToPdf ( const QString &  filePath,
const QPageLayout &  pageLayout 

◆ setHandleExternalUrlWithDesktopService()

void qSlicerWebWidget::setHandleExternalUrlWithDesktopService ( bool  enable)

◆ setHtml()

Q_INVOKABLE void qSlicerWebWidget::setHtml ( const QString &  html,
const QUrl &  baseUrl = QUrl() 

Convenience for setting the internal webView html from a QString.

◆ setInternalHosts()

void qSlicerWebWidget::setInternalHosts ( const QStringList &  hosts)

◆ setJavaScriptConsoleMessageLoggingEnabled()

void qSlicerWebWidget::setJavaScriptConsoleMessageLoggingEnabled ( bool  enable)

◆ setUrl

void qSlicerWebWidget::setUrl ( const QString &  url)

Convenience for setting the internal webView QUrl from a QString.

◆ url()

Q_INVOKABLE QString qSlicerWebWidget::url ( )

Convenience for setting the internal webView QUrl from a QString.

◆ webView()

Q_INVOKABLE QWebEngineView* qSlicerWebWidget::webView ( )

Return a reference to the QWebView used internally.

Friends And Related Function Documentation

◆ qSlicerWebEnginePage

friend class qSlicerWebEnginePage

Definition at line 52 of file qSlicerWebWidget.h.

Member Data Documentation

◆ d_ptr

QScopedPointer<qSlicerWebWidgetPrivate> qSlicerWebWidget::d_ptr

Definition at line 150 of file qSlicerWebWidget.h.

The documentation for this class was generated from the following file: