Enable Plugins in QWebView: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
So your here to learn how to enable plugins in the QWebView that you’ve added to your .ui file, so without a further ado, here you go:
So your here to learn how to enable plugins in the QWebView that you've added to your .ui file, so without a further ado, here you go:
 
<code>#include &lt;QtWebKit&amp;gt;<br />//make sure the correct headers are included so you can use globalSettings.<br />#include &quot;widget.h&amp;quot;<br />#include &quot;ui_widget.h&amp;quot;
 
Widget::Widget(QWidget *parent) :<br /> QWidget(parent),<br /> ui(new Ui::Widget)<br />{<br /> ui-&gt;setupUi(this);<br />//Create the ui.<br /> QWebSettings::globalSettings()-&gt;setAttribute(QWebSettings::PluginsEnabled, true);<br />//And, just enable plug-ins globally.<br />}
 
Widget::~Widget()<br />{<br /> delete ui;

Revision as of 06:44, 24 February 2015

So your here to learn how to enable plugins in the QWebView that you've added to your .ui file, so without a further ado, here you go:

#include <QtWebKit&gt;
//make sure the correct headers are included so you can use globalSettings.
#include "widget.h&quot;
#include "ui_widget.h&quot;

Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
//Create the ui.
QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);
//And, just enable plug-ins globally.
}

Widget::~Widget()
{
delete ui;