0
#include "mainwindow.h"
#include <QApplication>
#include <QtWebKit>
#include <QWebView>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWebView *view = new QWebView();
    QWebSettings::PluginsEnabled;
    view->load(QUrl("http://www.paulirish.com/demo/multi"));

    view->show();

    return a.exec();
}

I am trying to load a plugin in QtWebkit Webview but it isnt being loaded. I couldnt find the right path as mentioned Here, but it isnt loading. I have added Env. Variable QTWEBKIT_PLUGIN_PATH to System Variable & MOZ_PLUGIN_PATH was already in user variable, added by Foxit Reader. I tried placing the plugin dll file on both the directories corresponding to the Env. Variables but it isnt loading the plugin. After i palced the plugin in Moz_plugin_path, firefox was able to detect the plugin.

As for enabling the plugin in QTWebview i have tried using

QWebSettings::PluginsEnabled;

QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled,true);

view->page()->settings()->PluginsEnabled;

but found success with none of them, I am using Windows 8.1 and Qt 5.2

Shaurya Chaudhuri
  • 3,772
  • 6
  • 28
  • 58

2 Answers2

1

You should set the QWebSettings::PluginsEnabled attribute. The way you are doing it, nothing is happening.

Enable the attribute with the following code:

QWebSettings::globalSettings()->setAttribute(QWebSettings::PluginsEnabled, true);

Put this before your QWebView creation.

Refer to the documentation for more details:

QWebSettings Docs

  • Nope doesnt work. As i mentioned in the question, i tried three ways of enabling the plugin. Tried it again, placing the attribute before qWebView creation :( – Shaurya Chaudhuri Jan 22 '14 at 16:54
  • Btw if the plugin tries to access network connections it would be able to right? since it is a plugin, doing its own thing. The plugin i am trying to use is a TUIO listener. And the TUIO client send messages to a port, from which it listens. And is Javascript enabled by default? Tried the Docs, but it aint much help, did everything mentioned there – Shaurya Chaudhuri Jan 22 '14 at 17:00
  • Yes, the plugin will be able to access network connections. AFAIK, Javascript is enabled by default, especially after all the changes in the QtWebKit 5.2 module. Have you tried to enable plugins at the page level? (`view->page()->settings()->setAttribute(QWebSettings::PluginsEnabled, true);`? – Vinícius Gobbo A. de Oliveira Jan 22 '14 at 17:08
  • Yeap, tried that too. Is there any test plugin to see if plugins are being loaded, it might be just that the webpage isnt working in qt Webview, though it should. It just has a bit of Ajax, which should work when Js is enabled – Shaurya Chaudhuri Jan 22 '14 at 17:27
  • If there is, I don't know it. I tested the code you posted in your question in my Windows computer and it worked (I had to change to load a page with a PDF in it, so that the Adobe PDF plugin would load). I didn't had to setup any environment variable. Are you sure your QT_WEBKIT_PLUGIN_PATH is right? – Vinícius Gobbo A. de Oliveira Jan 22 '14 at 17:51
  • Try to load a page with a different plugin... maybe with a Flash player plugin. If it works, than the problem is with the TUIO plugin. One more thing, are compiling for 64 or 32 bit? And the TUIO plugin? – Vinícius Gobbo A. de Oliveira Jan 22 '14 at 17:54
  • Well i tried loading http://www.wbutech.net/Notices/y_l_el_paper_2014.pdf as the QURL, which should load the PDF file. But it isnt loading the PDF file. And in http://www.wbutech.net , the dropdown menus in the main website, isnt working in the Qwebview, though working in chrome and firefox – Shaurya Chaudhuri Jan 22 '14 at 18:00
  • Don't know what else could help... maybe posting at the Qt forum. The Qt community is the best =] Please, if you do post at the forum, send me a link with the thread so I can follow it up. – Vinícius Gobbo A. de Oliveira Jan 22 '14 at 18:04
  • Tried on Windows 8.1 with the latest updates and Qt 5.2. – Vinícius Gobbo A. de Oliveira Jan 22 '14 at 21:08
  • Hey did you do anything different, when you checked the code on your computer. I tried the same code on Linux but i am still having the same problem. Its getting over my head, and couldnt finish this damn thing because of this. Anyways if you can also suggest some alternatives to this webkit, it would be good :( – Shaurya Chaudhuri Jan 24 '14 at 15:27
  • Sorry... I did nothing different. This weekend I'll try to implement it again and test it on my Gentoo box. – Vinícius Gobbo A. de Oliveira Jan 24 '14 at 17:28
0

i have been through exactly the same situation. what solved my problem was to install adobe flash player plugin for NPAPI. Modern web browsers like Google Chrome and Firefox are often distributed with builtin flash player plugin. So Chrome/Firefox works well does not ensure that you have the proper flash plugin installed properly systemwide, which is needed by Qt5WebKit to enable local plugin support for Flash content.

so, make sure the adobe flash player plugin for NPAPI is installed, and hope it would solve your problem.

uwydoc
  • 83
  • 1
  • 1
  • 8