Qt World Summit: Submit your Presentation

[Solved] QtWebKit Bridge

  • I am trying to compile the bridge example (contained here: "qtwebkit-bridge.html":http://doc.qt.nokia.com/4.7/qtwebkit-bridge.html).

    As with the above, the only example snippets I can find on the web, start with a pointer to the page object:

    QWebFrame *frame = myWebPage->mainFrame();
    frame->addToJavaScriptWindowObject("someNameForMyObject", myObject);

    I have used the designer to create the QtWebView object, and in my MainWindow code, I try to get to the page object by using the ui object thus:

    QWebFrame * frame = ui->webView->page()->mainFrame();
    frame->addToJavaScriptWindowObject("NameOfMyObject", myObject);
    I get the following error: "Invalid Use of incomplete type 'struct QWebFrame'" pointing at the second line.

    I have even tried using a signal which fires when the QWebView object has loaded, with the same error.

    Does anyone have an example of how I am supposed to get the pointer to the frame object, so that I can initialise the webkit bridge call?

    Any sample code, would be much appreciated.

    [edit: Markup code and link, Tobias Hunger]

  • You need to include the qwebframe file in your cpp.

    #include <QWebFrame>

  • DaveSab, besides that, add the following to your .pro:

    QT += webkit

    Then you won't get a linker error. In "this link":http://doc.qt.nokia.com/4.7/qtwebkit.html#including-in-your-project you find additional info about it.

    PS: Please edit your post to format the code and links. Thanks =)

  • Doh! That was pretty basic mistake. :-(

    And yes, I have already run into the problem with the .pro file.

    Thanks for the quick responses, and I'll get with the program when it comes to formatting...

Log in to reply