1

QtWebkit-plugins is a library that provides features to the QWebView, eg SpellCheck and Notification Web API.

Read about:

I tried to compile the code in Windows, but my QWebView not working as expected, in other words, SpellCheck and Notification Web API not working. It's like I've been not-using QtWebkit-plugins. Which can be?

In the documentation that says to compile I have to run:

$ qmake
$ make && make install

Read more in QtWebkit-plugins repository

I'm using mingw, instead of make I used mingw32-make:

  • I compiled hunspell
  • Copied hunspell for C:\Qt5.4.0\5.4\mingw491_32\bin and C:\Qt5.4.0\5.4\mingw491_32\lib
  • I compiled qtwebkit-plugins using in cmd:

    qmake
    mingw32-make && mingw32-make install
    
  • mingw32-make generated libqtwebkitpluginsd.a and qtwebkitplugins.dll

  • Copied libqtwebkitpluginsd.a for C:\Qt5.4.0\5.4\mingw491_32\lib
  • Copied qtwebkitplugins.dll for C:\Qt5.4.0\5.4\mingw491_32\plugins\webkit and C:\Qt5.4.0\5.4\mingw491_32\bin

After that I compiled another simple project that uses QWebView then tested the SpellCheck in a <textarea spellcheck="true"></textarea> and did not work.

I tested the Notification Web API and also did not work.

Note: When running my project using QT_DEBUG_PLUGINS=1 and use Notification Web API in the application output tab (in QtCreator) returns:

Found metadata in lib C:/Qt5.4.0/5.4/mingw491_32/plugins/webkit/qtwebkitplugins.dll, metadata=
{
    "IID": "org.qtwebkit.QtWebKit.QtWebKitPlugin",
    "MetaData": {
    },
    "className": "QtWebKitPlugin",
    "debug": false,
    "version": 328704
}


loaded library "C:/Qt5.4.0/5.4/mingw491_32/plugins/webkit/qtwebkitplugins.dll"
QLibraryPrivate::unload succeeded on "C:/Qt5.4.0/5.4/mingw491_32/plugins/webkit/qtwebkitplugins.dll" 
QSystemTrayIcon::setVisible: No Icon set

It seems to me that the dll is loaded, it just is not working.

How do my projects work these features?

Protomen
  • 9,471
  • 9
  • 57
  • 124

1 Answers1

1

For this work in QT-5.2+ is necessary to modified the qwebkitplatformplugin.h file

Change this:

QT_BEGIN_NAMESPACE
Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.9");

By this:

QT_BEGIN_NAMESPACE
Q_DECLARE_INTERFACE(QWebKitPlatformPlugin,
    "org.qt-project.Qt.WebKit.PlatformPlugin/1.9");

If needed compatibility with QT-4.8 change the code for this:

QT_BEGIN_NAMESPACE
#if QT_VERSION >= 0x050200
Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "org.qt-project.Qt.WebKit.PlatformPlugin/1.9")
#else
Q_DECLARE_INTERFACE(QWebKitPlatformPlugin, "com.nokia.Qt.WebKit.PlatformPlugin/1.9")
#endif
QT_END_NAMESPACE
Protomen
  • 9,471
  • 9
  • 57
  • 124
  • thanks for providing your hard earned knowledge here, and thanks (i see now) for contributing this fix to the github repo too! This gives me renewed hope that I will be able to get this to work in my own application. I'm looking for further documentation on what needed to be done to get spell checking to actually work, and unfortunately there doesn't seem to be enough detail here for that. I found some interesting info in a google cache of SO question 17631200 that you asked and seem to have deleted. – stonecrusher Mar 20 '15 at 07:01
  • It would be helpful if you could provide a small sample of what you needed to add to a simple webview in order to get this to work. At the very least it doesn't currently do anything if the plugin is made to load in the 'Fancy Browser' Qt example. – stonecrusher Mar 20 '15 at 07:10
  • @stonecrusher I am creating a repository with a full example of use. The spell checker already works almost complete (including menu suggestions), missing only build `notifications web api`. :) Thanks! *Undeleted:* http://stackoverflow.com/q/17631200/1518921 – Protomen Mar 20 '15 at 17:52
  • You might also want to look at several spellcheck fixes commits made to qupzilla since they integrated that plugin. If I have the time I may try to backport those fixes into the plugin, but they've also included a bunch of qupzilla stuff too so it might be a bit of work. GitHub currently doesn't support searching by commit messages (http://stackoverflow.com/questions/18122628/how-to-search-for-a-commit-message-in-github), so I had to use gitk to search. Thanks for your work on this - I look forward to looking at the repo you mentioned. – stonecrusher Mar 20 '15 at 18:42
  • 1
    In my opinion, the way it is in `qupzilla` is very complex and difficult maintenance. Instead of creating a plugin, I'm using extending the `QApplication` to change dictionaries and other webkit plugin data and I moved the `speller.cpp` to another location to be used with both the plugin when with the application. But still a little disorganized. :) Thanks! – Protomen Mar 20 '15 at 18:46