Results 1 to 10 of 10

Thread: Accessing HTML5 capabilities

  1. #1
    Join Date
    May 2015
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Question Accessing HTML5 capabilities

    Hi everybody,

    I'd like to know how to access either navigator or document objects from Qt-C++/Qt-QML. Just so simple as, i.e.: navigator.getUserMedia.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Accessing HTML5 capabilities

    Both WebView and WebEngineView have appropriate APIs. Whether a particular call (e.g. getUserMedia()) is supported it is a different story.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2015
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Accessing HTML5 capabilities

    Hi Wysota, thanks for responding so fast.

    I'm interested in WebEngine. Do you know how to find out whether document or navigator are supported? I mean, what API should I use in order to access them, if accessing them is possible?

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Accessing HTML5 capabilities

    They are supported, it's a standard DOM API every browser needs to support.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2015
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Accessing HTML5 capabilities

    yes, but what should I write. I mean what syntax should I use because if I call them via JavaScript embedded in the browser or via a .js file they do not exist.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Accessing HTML5 capabilities

    Quote Originally Posted by Qtmac View Post
    yes, but what should I write.
    The same as with any other browser.

    javascript Code:
    1. import QtQuick 2.4
    2. import QtWebEngine 1.0
    3.  
    4. WebEngineView {
    5. width: 600
    6. height: 300
    7.  
    8. Component.onCompleted: loadHtml("<html><body><p id='demo'></p><script>document.getElementById('demo').innerHTML = navigator.userAgent</script></body></html>")
    9. }
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2015
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Accessing HTML5 capabilities

    Hi Wysota, could you, please, also add the C++ code part corresponding to this .qml? Thanks in advance for your reply.

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Accessing HTML5 capabilities

    There is no C++ part.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    May 2015
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Accessing HTML5 capabilities

    I added the following, but it does not show the window of WebEngineView in my main.qml.

    #include <QtGui/QGuiApplication>
    #include <QtQml/QQmlApplicationEngine>
    #include <QtWebEngine/qtwebengineglobal.h>

    int main( int argc, char *argv[ ] )
    {
    QGuiApplication app( argc, argv );

    QtWebEngine::initialize( );

    QQmlApplicationEngine appEngine;
    appEngine.load( QUrl( "qrc:/main.qml" ) );

    return app.exec();
    }

    It means I have no need of a main.cpp?

    This is my main.qml:
    import QtQuick 2.4
    import QtWebEngine 1.0
    import QtQuick.Window 2.0

    WebEngineView {
    width: 1200
    height: 900
    visible: true

    url: 'http://duckduckgo.com'
    //Component.onCompleted: loadHtml( "<html><body><p id='demo'></p><script>document.getElementById('demo').innerHTM L = navigator.userAgent</script></body></html>" )
    }

    and this is my main.cpp:
    #include <QtGui/QGuiApplication>
    #include <QtQml/QQmlApplicationEngine>
    #include <QtWebEngine/qtwebengineglobal.h>

    int main( int argc, char *argv[ ] )
    {
    QGuiApplication app( argc, argv );

    QtWebEngine::initialize( );

    QQmlApplicationEngine appEngine;
    appEngine.load( QUrl( "qrc:/main.qml" ) );

    return app.exec();
    }

    What's wrong? It doesn't show anything.

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Accessing HTML5 capabilities

    Quote Originally Posted by Qtmac View Post
    It means I have no need of a main.cpp?
    I ran my app with just qmlscene.

    What's wrong? It doesn't show anything.
    No idea, you probably don't have a window to show. But this is probably out of scope of this thread anyway. I gave you a working example, if you want, build upon it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QTreeWidget - extending check-box capabilities
    By mcherkas in forum Qt Programming
    Replies: 2
    Last Post: 1st November 2011, 11:51
  2. Capabilities problem
    By kapseli in forum Qt Programming
    Replies: 1
    Last Post: 18th August 2011, 11:36
  3. HTML5 with QT Webkit 4.6
    By Peter Jerald in forum Qt Programming
    Replies: 0
    Last Post: 12th July 2010, 10:18
  4. Static build of Qt: do I loose debug capabilities
    By euthymos in forum Installation and Deployment
    Replies: 1
    Last Post: 1st April 2009, 11:59
  5. MP3 capabilities in QT
    By Havard in forum Qt Programming
    Replies: 2
    Last Post: 2nd September 2008, 10:55

Tags for this Thread

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.