Results 1 to 6 of 6

Thread: How to call cpp file function from qml??

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2011
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Post How to call cpp file function from qml??

    Hi All,
    As i am new to qt quick i'm in need of calling a function from qml to cpp file, I am not able to write code for this. I tried this code...


    I am trying to add two numbers!!!I tried writing it in qml but could not get the result.. so i am looking to write a function for adding the nos. in the cpp file .
    i would call from qml to cpp function...

    QML CODE:
    javascript Code:
    1. property string i;
    2. property string j;
    3.  
    4. Button {
    5. id: one
    6. x: 59
    7. y: 131
    8. width: 41
    9. height: 42
    10. text: "1"
    11. onClicked:
    12. {
    13.  
    14. i = text
    15. textfield.text = textfield.text + i
    16. }
    17. }
    18. Button {
    19. id: two
    20. x: 119
    21. y: 131
    22. text: "2"
    23. onClicked:
    24. {
    25.  
    26. i = text
    27. textfield.text = textfield.text + i
    28.  
    29. }
    30.  
    31. }
    32.  
    33. Button {
    34. id: add
    35. x: 247
    36. y: 131
    37. text: "+"
    38. onClicked:
    39. {
    40. j = textfield.text
    41. ans = j
    42.  
    43. textfield.text = ""
    44.  
    45. funct.buttonclicked()
    To copy to clipboard, switch view to plain text mode 

    CPP CODE:
    Qt Code:
    1. void funct::buttonclicked()
    2. {
    3.  
    4. QString *s = new QString;
    5. s->show();
    6. .....???
    7. .....???
    8.  
    9. }
    To copy to clipboard, switch view to plain text mode 

    I am not able write from this!!!!

    Thanks in advance and Regards,
    Naufal.A
    Last edited by wysota; 24th January 2012 at 15:32. Reason: missing [code] tags

Similar Threads

  1. Qt function call in vb.net
    By abghosh in forum Qt Programming
    Replies: 7
    Last Post: 6th March 2010, 17:00
  2. Call to database function.
    By retto in forum Qt Programming
    Replies: 1
    Last Post: 14th September 2009, 12:29
  3. call function as Qstring
    By jcr in forum Qt Programming
    Replies: 1
    Last Post: 30th May 2009, 01:35
  4. function call
    By Walsi in forum Qt Programming
    Replies: 3
    Last Post: 12th June 2007, 09:13
  5. Cannot call function without object
    By Salazaar in forum Newbie
    Replies: 5
    Last Post: 11th June 2007, 14:55

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.