Results 1 to 3 of 3

Thread: passing var object javascript to c++ in function Q_INVOKABLE

  1. #1
    Join Date
    Mar 2016
    Posts
    9
    Qt products
    Qt5
    Platforms
    MacOS X

    Default passing var object javascript to c++ in function Q_INVOKABLE

    hello,
    i have read lot of subject about this but not resolve my problem.

    in doc qt it's read var is converting auto in qvariantmap.

    i have var javascript
    Qt Code:
    1. var ChartScatterData = {
    2. datasets: [ {
    3. name: "courbeTest",
    4. active: true,
    5. color: "rgba(220,220,220,0.5)",
    6. radiusPts:3,
    7. MinAxisx:0,
    8. MaxAxisx:9000,
    9. MinAxisy:10,
    10. MaxAxisy:18,
    11. stepPrimAxisx: 1000,
    12. stepSecAxisx: 100,
    13. stepPrimAxisy :1,
    14. stepSecAxisy:0.1,
    15. // tableau data
    16. data: [
    17. { x: 2000, y: 11 , hovered:false },
    18. { x: 3000, y: 12 , hovered:false},
    19. { x: 4000, y: 13 , hovered:false},
    20. { x: 5000, y: 14.5 , hovered:false}
    21. ]
    22. } ]
    23. }
    To copy to clipboard, switch view to plain text mode 


    i would like passing this with arg in function Q_INVOKABLE.
    i try to add function to arg Qvariantmap and read the attribut in c++.
    if is not possible , can you help me?
    or how pass this var in c++ in function Q_INVOKABLE?

    thank's

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

    Default Re: passing var object javascript to c++ in function Q_INVOKABLE

    Try QVariant as the function argument and then check in the C++ code what the variant contains.

    Cheers,
    _

  3. #3
    Join Date
    Mar 2016
    Posts
    9
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: passing var object javascript to c++ in function Q_INVOKABLE

    it's work with QVariant or QVariantMap,
    my problem is when i read var , i used "parent." and select the property with the editor.

    but value = undefined with qDebug, but if i used the "id", it's work's... arf...

    in Action{ } be careful

    thank's

Similar Threads

  1. Replies: 4
    Last Post: 2nd August 2012, 08:42
  2. Access Object Created by javascript in qml
    By alizadeh91 in forum Qt Quick
    Replies: 6
    Last Post: 23rd February 2012, 16:06
  3. How to call a function in the mother object from a child object?
    By Momergil in forum General Programming
    Replies: 4
    Last Post: 18th December 2011, 16:49
  4. Replies: 9
    Last Post: 29th November 2010, 13:12
  5. Replies: 3
    Last Post: 14th October 2008, 22:04

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.