Results 1 to 3 of 3

Thread: How to pass the Java script [var] from qml to .H/.CPP file

  1. #1
    Join Date
    Jul 2016
    Posts
    53
    Thanks
    13
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Default How to pass the Java script [var] from qml to .H/.CPP file

    Hi,

    I had fetched the list of products and stored in javascript var in main.qml. Now I want to pass the var to ListProduct.cpp.
    How should I pass the var.

    Code Snippets:

    main.qml [in button click event]

    var varResultArray;

    varResultArray = idPortalSearchItems.results[1];

    objHomeController.eveWriteXMLFile(varResultArray) //passing var from main.qml

    ListProduct.h
    ----------------
    Q_INVOKABLE bool eveWriteXMLFile(var ResultArray);//Showing the error.


    Query: What i have to declare in the declaration of the method in LisProduct.h to receive the var as the parameter.


    Thanks in advance.

  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: How to pass the Java script [var] from qml to .H/.CPP file

    Assuming you get the data from C++ in the first place, why not just use the same data type?

    Looks a lot like trying to make your life as hard as possible by artifically doing things in JavaScript instead of doing it in C++.

    Cheers,
    _

  3. #3
    Join Date
    Jul 2016
    Posts
    53
    Thanks
    13
    Qt products
    Qt4 Qt5
    Platforms
    Windows Android

    Default How to pass the javascript var from qml to CPP?

    I want to pass the results which stored in javascript var from the main.qml to the writeXML.cpp.
    I can see the count, the searchitems are fetched and want to write in XML format.

    How can I achieve this.

    Code snippet:

    var varResultArray;

    varResultArray = idPortalSearchItems.results[1];

    Query:

    How Can I pass it by Javascript var Ex:
    objHomeController.eveWriteXMLFile(varResultArray ); //Passing an Js variable


    writeXML.h
    ------------

    What will be the datatype of the argument of the method?
    Ex:
    Q_INVOKABLE bool eveWriteXMLFile(??????? varResultArray ); //What will be the datatype?




    Thanks In advance.

Similar Threads

  1. Qt script combined with java script
    By prachi kamble in forum Newbie
    Replies: 8
    Last Post: 16th April 2015, 14:30
  2. Howto pass commands to the linker script via .pro file
    By M4chin3 in forum Qt Programming
    Replies: 5
    Last Post: 31st March 2015, 12:52
  3. Qml java script
    By ganeshgladish in forum Newbie
    Replies: 6
    Last Post: 7th June 2013, 17:52
  4. java script function
    By ganeshgladish in forum Newbie
    Replies: 1
    Last Post: 5th June 2013, 14:19
  5. Java Script on Qt4.5
    By kavinsiva in forum Newbie
    Replies: 1
    Last Post: 7th October 2009, 14:08

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.