×

Discussion Board

Results 1 to 9 of 9

Hybrid View

  1. #1
    Registered User
    Join Date
    Sep 2010
    Posts
    31

    Qt.openUrlExternally does not work as expected

    Hi,
    I have the following problem:

    Code in .cpp file:
    in onLoadFinished slot i have following piece of code:

    view->page()->mainFrame()->evaluateJavaScript("test()");

    Code in .js File:

    function test(){
    alert('Hello');
    Qt.openUrlExternally("http://www.nokia.com");
    }

    Problem is that,test() function is getting called and also shows alert box "Hello" but Qt.openUrlExternally("http://www.nokia.com") does not work.

    Thanks

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: Qt.openUrlExternally does not work as expected

    Looks like you have multiple thread for same question.
    http://www.developer.nokia.com/Commu...script-problem
    Rather then creating a new thread you should check your older thread and provide required inputs .

    Why do you want to call C++ method from javascript that is called from C++ code? You can directly do it in "onLoadFinished".

    Anyway, You can not call "Qt.openUrlExternally" directly from javascript. Instead add your object (check addToJavaScriptWindowObject) to Java Script, then call some method of that object and call "Qt.openUrlExternally" from this method.

  3. #3
    Registered User
    Join Date
    Sep 2010
    Posts
    31

    Re: Qt.openUrlExternally does not work as expected

    Thanks savaj,

    it would be great if you provide me code snippet of usage of this function (addToJavaScriptWindowObject).

    Thanks

  4. #4
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: Qt.openUrlExternally does not work as expected

    I really don't have any code example, but you can just try yourself and let us know if facing any problem.

  5. #5
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: Qt.openUrlExternally does not work as expected

    In-fact check this example.

  6. #6
    Registered User
    Join Date
    Sep 2010
    Posts
    31

    Re: Qt.openUrlExternally does not work as expected

    Thanks savaj,

    In .cpp file my code is as follows:

    connect( view->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),this, SLOT(populateJavaScriptWindowObject()) );

    void WebviewItem:opulateJavaScriptWindowObject()
    {
    view->page()->mainFrame()->addToJavaScriptWindowObject("view",view);
    }

    Now how can i use "view" object in javascript file ?

  7. #7
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Qt.openUrlExternally does not work as expected

    Still I don't understand why you want to open an URL with a QML function.
    What is your real target?

    addToJavaScriptWindowObject let the QObject available to javascript. You have to use javascript methods to find the view object and use its properties.. look at http://en.wikibooks.org/wiki/JavaScr...nding_Elements
    Last edited by gnuton; 2011-12-01 at 12:02.

  8. #8
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: Qt.openUrlExternally does not work as expected

    Try view.yourCppMethod().

  9. #9
    Registered User
    Join Date
    Sep 2010
    Posts
    31

    Re: Qt.openUrlExternally does not work as expected

    Thanks savaj,

    Working fine now.. :-)

Similar Threads

  1. Qt.openUrlExternally() gives parse error
    By manikantan in forum [Archived] Qt Quick
    Replies: 1
    Last Post: 2011-09-19, 15:26
  2. Graphics3D.setViewport() does not work as expected on S60 3rd FP2
    By gautierb in forum Mobile Java Media (Graphics & Sounds)
    Replies: 3
    Last Post: 2010-01-03, 20:11
  3. RWsSession,SimulateKeyEvent doenst work as expected
    By Priju Jacob Paul in forum Symbian
    Replies: 6
    Last Post: 2007-07-30, 14:01
  4. Replies: 1
    Last Post: 2006-03-04, 01:33
  5. Replies: 0
    Last Post: 2004-12-20, 21:48

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×