Results 1 to 8 of 8

Thread: Accessing Javascript function from QT/C++

Hybrid View

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

    Default Re: Accessing Javascript function from QT/C++

    This really looks like something were a way better solution exists, but if you really need to have this reverse dependency then just add a gpsOneShotUpdate function to your root object and make it call the function in the script file.

    What is the returned value? I.e. what does it mean?

    Cheers,
    _

  2. #2
    Join Date
    May 2011
    Posts
    81
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11
    Thanks
    6
    Thanked 5 Times in 4 Posts

    Default Re: Accessing Javascript function from QT/C++

    There is no returned value...it only sets some text on a couple of labels, then hides & shows 2 QML 'pages'.

    I am open to any "way better solution"....

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

    Default Re: Accessing Javascript function from QT/C++

    You use Q_RETURN_ARG, so I assume the return value was important to you.

    If your value API an exported object instance, i.e. one exported using setContextProperty(), or are you instantiating it from QML?
    In either case signalling the end of the GPS update would be done with a signal of that class, but depending on how you create the instance you will handle the signal differently.

    Cheers,
    _

  4. #4
    Join Date
    May 2011
    Posts
    81
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11
    Thanks
    6
    Thanked 5 Times in 4 Posts

    Default Re: Accessing Javascript function from QT/C++

    If your value API an exported object instance, i.e. one exported using setContextProperty(), or are you instantiating it from QML?
    I don't understand what you are asking...

    ==========================

    For now, I am trying to add "interface" functions in my Main.QML that calls my javascript functions as you suggested earlier.
    Last edited by scgrant327; 8th February 2016 at 19:15.

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

    Default Re: Accessing Javascript function from QT/C++

    You wrote that you are getting some values in C++ and then putting these into UI elements.

    I assume you are doing this by having that data in properties of an object and using bindings to these properties in QML.

    So that object just needs another signal.

    Cheers,
    _

Similar Threads

  1. Call JavaScript function with parameters from Qt C++
    By qt_developer in forum Qt Programming
    Replies: 5
    Last Post: 13th January 2015, 00:31
  2. Call a JavaScript function from C++ using QtWebkit
    By Rastersoft in forum Qt Programming
    Replies: 9
    Last Post: 14th May 2014, 12:03
  3. Replies: 4
    Last Post: 2nd August 2012, 07:42
  4. Pass data from QT to javascript function
    By thanhluanbk88 in forum Qt Programming
    Replies: 3
    Last Post: 3rd March 2011, 10:40
  5. WebKit - accessing javascript results + googleMap
    By giusepped in forum Qt Programming
    Replies: 10
    Last Post: 30th May 2009, 00:01

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
  •  
Qt is a trademark of The Qt Company.