Results 1 to 2 of 2

Thread: How to pass variables as reference from C++ to QML

  1. #1
    Join Date
    Jul 2010
    Posts
    5
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default How to pass variables as reference from C++ to QML

    I need to expose a (slot) function from C++ into QML with parameters as reference to be used on the QML side:

    C++ side
    Qt Code:
    1. class A : public QObject
    2. {
    3.  
    4. public slot:
    5. void func(int& i, QString& s);
    6. }
    To copy to clipboard, switch view to plain text mode 

    QML side
    Qt Code:
    1. onClicked: {
    2. objectA.func(i,s)
    3. ..do something with i
    4. ..do something with s
    5. }
    To copy to clipboard, switch view to plain text mode 

    When I run the application, I receive an error message saying that javascript doesn't recognise i and s parameters. Any idea?

  2. #2
    Join Date
    Nov 2010
    Posts
    82
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to pass variables as reference from C++ to QML

    we will need more info:
    in your javascript i and s doesn't seems to be defined.
    were do they come from ?

Similar Threads

  1. Casting variables
    By axisdj in forum Newbie
    Replies: 1
    Last Post: 6th September 2010, 18:00
  2. environmental variables
    By mohanakrishnan in forum Newbie
    Replies: 4
    Last Post: 26th October 2009, 10:43
  3. Pass by reference in QtScript
    By songyu_us in forum Qt Programming
    Replies: 0
    Last Post: 14th July 2009, 18:59
  4. Pass by reference
    By vermarajeev in forum General Programming
    Replies: 6
    Last Post: 20th July 2007, 15:53
  5. pass variables between 2 forms
    By restiz in forum Qt Programming
    Replies: 7
    Last Post: 17th June 2006, 17:13

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.