MeVisLab Scripting Reference
MLABWebEngineViewControl Class Reference

#include <mlabWebEngineViewControl.h>

Inherits MLABSimpleWidgetControl.

Public Slots

Direct QtWebEngine access


void setUrl (const QUrl &url)
 
QUrl url () const
 
void setUrlFromFileName (const QString &absoluteFileName)
 
void setUrlFromString (const QString &urlString)
 
void setHtmlFromString (const QString &html, const QUrl &baseUrl=QUrl())
 
QString selectedText ()
 
QWebEnginePage * webPage ()
 
void setWebPage (QWebEnginePage *page)
 
QWebEngineView * webView ()
 
void addObjectToWebChannel (const QString &name, QObject *object)
 
void removeObjectFromWebChannel (QObject *object)
 
void runJavaScript (const QString &script)
 
void runJavaScript (const QString &script, const QVariant &resultCallback, bool synchronous=false)
 
void openDevTools ()
 
void setPrintingEnabled (bool enabled)
 
bool isPrintingEnabled () const
 
void printPage (QPrinter *printer, const QVariant &resultCallback)
 
bool showPrintDialog ()
 
- Public Slots inherited from MLABWidgetControl
void adjustSize ()
 
virtual void setEnabled (bool flag)
 
virtual void setVisible (bool flag)
 
virtual bool isVisible ()
 
virtual void setFocus ()
 
virtual bool hasFocus ()
 
virtual void setToolTip (const QString &string)
 
virtual void setWhatsThis (const QString &string)
 
void displayWhatsThis ()
 
void displayWhatsThis (const QString &text)
 
virtual void setTitle (const QString &)
 
QWidget * widget ()
 
QLayout * layout ()
 
virtual QString windowHandle ()
 
virtual bool createScreenshot (const QString &filename, bool grabFromScreen=true, bool scaleToLowRes=false)
 
bool isReloadable () const
 
void reload (MLABTree *tree)
 
QString createGlobalScreenshot ()
 
QString applicationName ()
 
QSize size ()
 
int width ()
 
int height ()
 
int minWidth ()
 
int minHeight ()
 
int maxWidth ()
 
int maxHeight ()
 
virtual void setMinWidth (int s)
 
virtual void setMinHeight (int s)
 
void setMaxWidth (int s)
 
void setMaxHeight (int s)
 
QSize sizeHint ()
 
QSize minSize ()
 
QSize maxSize ()
 
void setMinSize (QSize size)
 
void setMaxSize (QSize size)
 
void updateLayout ()
 
int windowID ()
 
MLABWidgetControlcontrol (const QString &name)
 
float scaleFactor ()
 
MLABModulemodule ()
 
QString getType ()
 
QString getName ()
 
bool acceptDrops ()
 
void setAcceptDrops (bool flag)
 
void raiseWidget ()
 
void setStyleSheetFromString (const QString &styleSheetText)
 
void setStyleSheetFromFile (const QString &styleSheetFileName)
 
MLABTreetree ()
 
void updateMaxSize ()
 
bool expandX ()
 
bool expandY ()
 
MLABTreePtr getDefaultTagValues () const
 
virtual bool hasUncommittedChanges () const
 
virtual void applyUncommittedChanges ()
 
virtual void revertUncommittedChanges ()
 
MLABFieldfield () const
 

Detailed Description

WebEngineView control offers a HTML browser engine based on Chromium/QtWebEngine.

To facilitate debugging of the control, you can enable the logConsoleOutput MDL tag. Another option is to set the environment variable QTWEBENGINE_REMOTE_DEBUGGING to a port number (e.g. 4567) and then connect a Google Chrome browser to http://127.0.0.1:4567/ to use the remote debugging tools.

MDL reference: WebEngineView

Member Function Documentation

◆ addObjectToWebChannel

void MLABWebEngineViewControl::addObjectToWebChannel ( const QString & name,
QObject * object )
slot

Registers the given object to the web channel It needs to be called before setting the content via setUrl().

It requires the usage of qwebchannel.js inside of the HTML document.

◆ isPrintingEnabled

bool MLABWebEngineViewControl::isPrintingEnabled ( ) const
inlineslot

Return if printing is enabled.

◆ openDevTools

void MLABWebEngineViewControl::openDevTools ( )
slot

Open a new window with developer tools for this web view.

◆ printPage

void MLABWebEngineViewControl::printPage ( QPrinter * printer,
const QVariant & resultCallback )
slot

Prints the current QWebEnginePage using the given printer.

Calls the result callback with a success indicating boolean, if the callback is valid. Otherwise prints an error in case of a failure. You must ensure that printer stays valid until the result callback has been called.

If you want to print to a PDF document, it is recommended that you rather use webView().printToPdf(filename, ...), as documented here: https://doc.qt.io/qt-6/qwebengineview.html#printToPdf, since this doesn't use the detour of printing to a bitmap first.

You might need to execute

from PythonQt import QtWebEngineWidgets

before you can call printToPdf

◆ removeObjectFromWebChannel

void MLABWebEngineViewControl::removeObjectFromWebChannel ( QObject * object)
slot

Deregister an object previously registered with addObjectToWebChannel.

This acts the same as if the registered object was destroyed.

◆ runJavaScript [1/2]

void MLABWebEngineViewControl::runJavaScript ( const QString & script)
slot

Runs the given script (asynchronously).

◆ runJavaScript [2/2]

void MLABWebEngineViewControl::runJavaScript ( const QString & script,
const QVariant & resultCallback,
bool synchronous = false )
slot

Runs the given script (asynchronously as default) and calls the result callback with the result of the last JavaScript statement.

◆ selectedText

QString MLABWebEngineViewControl::selectedText ( )
slot

Returns the currently selected text.

◆ setHtmlFromString

void MLABWebEngineViewControl::setHtmlFromString ( const QString & html,
const QUrl & baseUrl = QUrl() )
slot

Set the html data from the given string.

If no baseUrl is given, the base url is the of the MDL code that created this WebView.

◆ setPrintingEnabled

void MLABWebEngineViewControl::setPrintingEnabled ( bool enabled)
slot

Sets if printing is enabled (connects current QWebEnginePage::printRequested() to showPrintDialog() slot if enabled is true).

◆ setUrl

void MLABWebEngineViewControl::setUrl ( const QUrl & url)
slot

Set the url to load.

◆ setUrlFromFileName

void MLABWebEngineViewControl::setUrlFromFileName ( const QString & absoluteFileName)
slot

Set the url from the given local filename.

◆ setUrlFromString

void MLABWebEngineViewControl::setUrlFromString ( const QString & urlString)
slot

Set the url from the given string.

◆ setWebPage

void MLABWebEngineViewControl::setWebPage ( QWebEnginePage * page)
slot

Allows to set your own QWebEnginePage, which you can derive using Python.

MDL link delegation and redirection to debug output will not work with your own widget, but you can re-implement that in Python.

◆ showPrintDialog

bool MLABWebEngineViewControl::showPrintDialog ( )
slot

Shows a print dialog which starts printing, if the user accepts it. Returns if the user accepted it.

◆ url

QUrl MLABWebEngineViewControl::url ( ) const
slot

Returns current url.

◆ webPage

QWebEnginePage * MLABWebEngineViewControl::webPage ( )
slot

Get the access to the underlying page.

Import QtWebEngineWidgets to allow full scripting of this class.

from PythonQt import QtWebEngineWidgets

◆ webView

QWebEngineView * MLABWebEngineViewControl::webView ( )
slot

Get the access to the underlying view.

Import QtWebEngineWidgets to allow full scripting of this class.

from PythonQt import QtWebEngineWidgets