Em primeiro lugar, gostaria de dizer que não tenho muita experiência em Qt, mas gostaria de incluir um novo recurso no componente QML WebView existente para definir uma lista de valores de cabeçalho, incluindo o cabeçalho do User Agent, para ser enviado ao solicitar um novo URL. A maneira de realizá-lo eu pensei ser subclasse da classe QWebView (por exemplo, 'MyWebView' estendendo QWebView) e registrar essa classe com
qmlRegisterType<MyWebView>(uri, 1, 0, "MyWebView");
Eu criei um aplicativo "QML Extension Library + Tabbed Toque UI" chamado MyApp para registrar a classe MyWebView, quando codificada, usando classe de back-end pré-criada. A única coisa que fiz até agora é criar uma primeira abordagem do arquivo .h dessa maneira:
#ifndef MYWEBVIEW_H
#define MYWEBVIEW_H
#include <QtWebKitWidgets/QWebView>
class MyWebView : public QWebView
{
Q_OBJECT
public:
explicit MyWebView(QWebView *parent = 0);
};
#endif // MYWEBVIEW_H
com este .cpp
#include "mywebview.h"
MyWebView::MyWebView(QWebView *parent) :
QWebView(parent)
{
}
Eu não tenho nenhum dispositivo conectado ao meu laptop, por isso só uso a distribuição de desktop Raring Ringtail para desenvolvimento. Com esse arquivo extra adicionado, a compilação funciona, mas quando eu tento executar ou depurar o projeto (para ver pelo menos o MyApp.qml padrão funcionando), esses erros são mostrados:
Iniciando / usr / lib / x86_64-linux-gnu / qt5 / bin / qmlscene ...
file: /// [DEBUG_PATH] /app/MyApp.qml:30 Tipo HelloTab indisponível
file: /// [DEBUG_PATH] /app/ui/HelloTab.qml:3 plugin não pode ser carregado para
módulo "MyApp": não é possível carregar a biblioteca
[DEBUG_PATH] /backend/modules/MyApp/libMyApp.so:
([DEBUG_PATH] /backend/modules/MyApp/libMyApp.so: símbolo indefinido:
_ZN8QWebView16staticMetaObjectE)
então eu suponho ... algo não está bem configurado? Você tem alguma ideia do que está acontecendo?
Poderia ser possível que a versão do Ubuntu que estou usando seja de 64 bits ?. Whey eu executo
ldd -r libMyApp.so
existem linhas dizendo que as classes do WebKit são indefinidas:
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)