Sunday, June 25, 2017

application development - Extend existing QML Component from C++ plugin

First of all, I would like to say that I'm not very experienced in Qt, but I would like to include a new feature in existing QML WebView component to set a list of header values, included User Agent header, to be sent when requesting a new url. The way to perform it I thought to be subclassing QWebView class (for example 'MyWebView' extending QWebView) and register that class with


qmlRegisterType(uri, 1, 0, "MyWebView");

I have created a "QML Extension Library + Tabbed Touch UI" application called MyApp to register MyWebView class, when coded, using precreated backend class. The only thing I have done until now is creating a first approach .h file this way:


#ifndef MYWEBVIEW_H
#define MYWEBVIEW_H
#include
class MyWebView : public QWebView
{
Q_OBJECT
public:
explicit MyWebView(QWebView *parent = 0);
};
#endif // MYWEBVIEW_H

with this .cpp


#include "mywebview.h"
MyWebView::MyWebView(QWebView *parent) :
QWebView(parent)
{
}

I don't have any device connected to my laptop, so I only use Raring Ringtail desktop distribution for developing. With this extra added file, compilation works, but when I try to run or debug the project (to see at least the default MyApp.qml working) these errors are shown:



Starting /usr/lib/x86_64-linux-gnu/qt5/bin/qmlscene...


file:///[DEBUG_PATH]/app/MyApp.qml:30 Type HelloTab unavailable
file:///[DEBUG_PATH]/app/ui/HelloTab.qml:3 plugin cannot be loaded for
module "MyApp": Cannot load library
[DEBUG_PATH]/backend/modules/MyApp/libMyApp.so:
([DEBUG_PATH]/backend/modules/MyApp/libMyApp.so: undefined symbol:
_ZN8QWebView16staticMetaObjectE)



so I suppose... is something not well configured? Does you have any idea of what is happenning?


Could it be possible the Ubuntu version I am using is 64bit?. Whey I execute


ldd -r libMyApp.so

there are may lines saying WebKit classes are undefined:


    linux-vdso.so.1 =>  (0x00007ffffb5d1000)
libQt5Qml.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5 (0x00007ff9e1baa000)
libQt5Core.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007ff9e1595000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007ff9e1291000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007ff9e107b000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff9e0cb3000)
libQt5Network.so.5 => /usr/lib/x86_64-linux-gnu/libQt5Network.so.5 (0x00007ff9e097b000)
libQt5V8.so.5 => /usr/lib/x86_64-linux-gnu/libQt5V8.so.5 (0x00007ff9e0337000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007ff9e0032000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff9dfe14000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007ff9dfbfd000)
libicui18n.so.48 => /usr/lib/x86_64-linux-gnu/libicui18n.so.48 (0x00007ff9df837000)
libicuuc.so.48 => /usr/lib/x86_64-linux-gnu/libicuuc.so.48 (0x00007ff9df4cb000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff9df2c7000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007ff9defcb000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007ff9dedc2000)
/lib64/ld-linux-x86-64.so.2 (0x00007ff9e2205000)
libicudata.so.48 => /usr/lib/x86_64-linux-gnu/libicudata.so.48 (0x00007ff9dda52000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007ff9dd812000)
undefined symbol: _ZN8QWebView16staticMetaObjectE (./libMyApp.so)
undefined symbol: _ZN8QWebView5eventEP6QEvent (./libMyApp.so)
undefined symbol: _ZNK7QWidget7devTypeEv (./libMyApp.so)
undefined symbol: _ZN7QWidget10setVisibleEb (./libMyApp.so)
undefined symbol: _ZNK8QWebView8sizeHintEv (./libMyApp.so)
undefined symbol: _ZNK7QWidget15minimumSizeHintEv (./libMyApp.so)
undefined symbol: _ZNK7QWidget14heightForWidthEi (./libMyApp.so)
undefined symbol: _ZNK7QWidget17hasHeightForWidthEv (./libMyApp.so)
undefined symbol: _ZNK7QWidget11paintEngineEv (./libMyApp.so)
undefined symbol: _ZN8QWebView15mousePressEventEP11QMouseEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView17mouseReleaseEventEP11QMouseEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView21mouseDoubleClickEventEP11QMouseEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView14mouseMoveEventEP11QMouseEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView10wheelEventEP11QWheelEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView13keyPressEventEP9QKeyEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView15keyReleaseEventEP9QKeyEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView12focusInEventEP11QFocusEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView13focusOutEventEP11QFocusEvent (./libMyApp.so)
undefined symbol: _ZN7QWidget10enterEventEP6QEvent (./libMyApp.so)
undefined symbol: _ZN7QWidget10leaveEventEP6QEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView10paintEventEP11QPaintEvent (./libMyApp.so)
undefined symbol: _ZN7QWidget9moveEventEP10QMoveEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView11resizeEventEP12QResizeEvent (./libMyApp.so)
undefined symbol: _ZN7QWidget10closeEventEP11QCloseEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView16contextMenuEventEP17QContextMenuEvent (./libMyApp.so)
undefined symbol: _ZN7QWidget11tabletEventEP12QTabletEvent (./libMyApp.so)
undefined symbol: _ZN7QWidget11actionEventEP12QActionEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView14dragEnterEventEP15QDragEnterEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView13dragMoveEventEP14QDragMoveEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView14dragLeaveEventEP15QDragLeaveEvent (./libMyApp.so)
undefined symbol: _ZN8QWebView9dropEventEP10QDropEvent (./libMyApp.so)
undefined symbol: _ZN7QWidget9showEventEP10QShowEvent (./libMyApp.so)
undefined symbol: _ZN7QWidget9hideEventEP10QHideEvent (./libMyApp.so)
undefined symbol: _ZN7QWidget11nativeEventERK10QByteArrayPvPl (./libMyApp.so)
undefined symbol: _ZN8QWebView11changeEventEP6QEvent (./libMyApp.so)
undefined symbol: _ZNK7QWidget6metricEN12QPaintDevice17PaintDeviceMetricE (./libMyApp.so)
undefined symbol: _ZNK7QWidget11initPainterEP8QPainter (./libMyApp.so)
undefined symbol: _ZNK7QWidget10redirectedEP6QPoint (./libMyApp.so)
undefined symbol: _ZNK7QWidget13sharedPainterEv (./libMyApp.so)
undefined symbol: _ZN8QWebView16inputMethodEventEP17QInputMethodEvent (./libMyApp.so)
undefined symbol: _ZNK8QWebView16inputMethodQueryEN2Qt16InputMethodQueryE (./libMyApp.so)
undefined symbol: _ZN8QWebView18focusNextPrevChildEb (./libMyApp.so)
undefined symbol: _ZN8QWebView12createWindowEN8QWebPage13WebWindowTypeE (./libMyApp.so)
undefined symbol: _ZThn16_NK7QWidget7devTypeEv (./libMyApp.so)
undefined symbol: _ZThn16_NK7QWidget11paintEngineEv (./libMyApp.so)
undefined symbol: _ZThn16_NK7QWidget6metricEN12QPaintDevice17PaintDeviceMetricE (./libMyApp.so)
undefined symbol: _ZThn16_NK7QWidget11initPainterEP8QPainter (./libMyApp.so)
undefined symbol: _ZThn16_NK7QWidget10redirectedEP6QPoint (./libMyApp.so)
undefined symbol: _ZThn16_NK7QWidget13sharedPainterEv (./libMyApp.so)
undefined symbol: _ZTI8QWebView (./libMyApp.so)
undefined symbol: _ZN8QWebPage16staticMetaObjectE (./libMyApp.so)
undefined symbol: _ZN8QWebPage5eventEP6QEvent (./libMyApp.so)
undefined symbol: _ZN8QWebPage13triggerActionENS_9WebActionEb (./libMyApp.so)
undefined symbol: _ZN8QWebPage9extensionENS_9ExtensionEPKNS_15ExtensionOptionEPNS_15ExtensionReturnE (./libMyApp.so)
undefined symbol: _ZNK8QWebPage17supportsExtensionENS_9ExtensionE (./libMyApp.so)
undefined symbol: _ZN8QWebPage25shouldInterruptJavaScriptEv (./libMyApp.so)
undefined symbol: _ZN8QWebPage12createWindowENS_13WebWindowTypeE (./libMyApp.so)
undefined symbol: _ZN8QWebPage12createPluginERK7QStringRK4QUrlRK11QStringListS8_ (./libMyApp.so)
undefined symbol: _ZN8QWebPage23acceptNavigationRequestEP9QWebFrameRK15QNetworkRequestNS_14NavigationTypeE (./libMyApp.so)
undefined symbol: _ZN8QWebPage10chooseFileEP9QWebFrameRK7QString (./libMyApp.so)
undefined symbol: _ZN8QWebPage15javaScriptAlertEP9QWebFrameRK7QString (./libMyApp.so)
undefined symbol: _ZN8QWebPage17javaScriptConfirmEP9QWebFrameRK7QString (./libMyApp.so)
undefined symbol: _ZN8QWebPage16javaScriptPromptEP9QWebFrameRK7QStringS4_PS2_ (./libMyApp.so)
undefined symbol: _ZN8QWebPage24javaScriptConsoleMessageERK7QStringiS2_ (./libMyApp.so)
undefined symbol: _ZNK8QWebPage15userAgentForUrlERK4QUrl (./libMyApp.so)
undefined symbol: _ZTI8QWebPage (./libMyApp.so)
undefined symbol: _ZN8QWebView11qt_metacastEPKc (./libMyApp.so)
undefined symbol: _ZN8QWebViewD2Ev (./libMyApp.so)
undefined symbol: _ZN8QWebView11qt_metacallEN11QMetaObject4CallEiPPv (./libMyApp.so)
undefined symbol: _ZN8QWebPage11qt_metacallEN11QMetaObject4CallEiPPv (./libMyApp.so)
undefined symbol: _ZN8QWebViewC2EP7QWidget (./libMyApp.so)
undefined symbol: _ZN8QWebPageD2Ev (./libMyApp.so)
undefined symbol: _ZN8QWebPage11qt_metacastEPKc (./libMyApp.so)
undefined symbol: _ZN8QWebPageC2EP7QObject (./libMyApp.so)

No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...