Discussion Board

Results 1 to 9 of 9

Hybrid View

  1. #1
    Registered User Siddharth5's Avatar
    Join Date
    Sep 2010
    Posts
    31
    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
    Nokia Developer Champion savaj's Avatar
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034
    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 Siddharth5's Avatar
    Join Date
    Sep 2010
    Posts
    31
    Thanks savaj,

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

    Thanks

  4. #4
    Nokia Developer Champion savaj's Avatar
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034
    I really don't have any code example, but you can just try yourself and let us know if facing any problem.

  5. #5
    Nokia Developer Champion savaj's Avatar
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034
    In-fact check this example.

  6. #6
    Registered User Siddharth5's Avatar
    Join Date
    Sep 2010
    Posts
    31
    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
    Nokia Developer Moderator gnuton's Avatar
    Join Date
    Mar 2009
    Posts
    1,024
    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
    Nokia Developer Champion savaj's Avatar
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034
    Try view.yourCppMethod().

  9. #9
    Registered User Siddharth5's Avatar
    Join Date
    Sep 2010
    Posts
    31
    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 C++
    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
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved