Results 1 to 4 of 4

Thread: Passing binary data between Qt classes and JS through Qt Webkit bridge

  1. #1
    Join Date
    Sep 2012
    Location
    Kharkiv
    Posts
    17
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Passing binary data between Qt classes and JS through Qt Webkit bridge

    Hi all,

    My web application needs to have access to sockets (WebSockets is not an option in my case). The application will work in Webkit browser so I decided to write a plugin for webkit browser using Qt Webkit bridge technology. It seems that QTcpSocket should absolutely suite my needs.

    But unfortunately after reading through the documentation on Qt Webkit bridge I didn't find any data type which will be suitable for passing binary data between plugin and JS application. In the documentation only a few data types which supposed to be automatically converted between Qt and JS are described.

    The problem is that e.g. QIODevice::write method takes either char* or QByteArray.

    After my investigation I can make a conclusion that the only way to pass binary data between Qt and JS is to pack it in string. But probably there are better ways for that.

    Any suggestions are welcome. Thanks.

  2. #2
    Join Date
    Sep 2012
    Location
    Kharkiv
    Posts
    17
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Passing binary data between Qt classes and JS through Qt Webkit bridge

    It seems that starting from Qt Webkit 5 they added support of Uint8Array in bridge. If I'm looking into a proper place (qtwebkit/Source/WebCore/bridge/qt/qt_runtime.cpp). But anyway I still can't figure out how to properly pass such type of data between Qt and JS.

  3. #3
    Join Date
    Sep 2012
    Location
    Kharkiv
    Posts
    17
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Passing binary data between Qt classes and JS through Qt Webkit bridge

    The problem resolved. It turned out that in Qt webkit 5.x QByteArray is mapped to Uint8ClampedArray and vise versa when passing through Qt webkit bridge. But I think the documentation for Qt webkit bridge should be updated because I had to read sources to find it out which took me a lot of time.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Passing binary data between Qt classes and JS through Qt Webkit bridge

    I think it is possible to file a bug report against the documentation.

    You could of course also contribute to Qt documentation yourself

    Cheers,
    _

Similar Threads

  1. Passing of Parameters in two classes
    By StarRocks in forum Qt Programming
    Replies: 4
    Last Post: 17th October 2012, 06:48
  2. Passing QList of custom classes using dbus
    By Luc4 in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2011, 17:20
  3. Webkit Bridge Tutorial Missing??
    By rick,reynolds in forum Newbie
    Replies: 1
    Last Post: 3rd November 2010, 00:41
  4. passing backspace key to Webkit plugin
    By shayz in forum Newbie
    Replies: 0
    Last Post: 15th October 2010, 10:36
  5. Replies: 4
    Last Post: 2nd September 2007, 20:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.