Results 1 to 3 of 3

Thread: How to connect functions of QML files?

  1. #1
    Join Date
    Jul 2012
    Posts
    26
    Thanks
    3
    Platforms
    Windows

    Default How to connect functions of QML files?

    Hello guys,

    I have 4 different QML files (Item1.qml ; Item2.qml ; Item3.qml ; Item4.qml) and a MainPage.qml file. I use them like this:

    Qt Code:
    1. ...
    2.  
    3. Item1 {
    4. id: item1
    5. ...
    6. }
    7.  
    8. Item2 {
    9. id: item2
    10. ...
    11. }
    12.  
    13. Item3 {
    14. id: item3
    15. ...
    16. }
    17.  
    18. Item4 {
    19. id: item4
    20. ...
    21. }
    22.  
    23. ...
    To copy to clipboard, switch view to plain text mode 

    I added this code to my main file, MainPage.qml, and it works perfectly with my animations. However I have a problem: 4 different Item file has same function and I want to use these functions together (for example if it is a calculation function, then, I want to add my main file total calculation).

    How can I connect them? Any idea?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to connect functions of QML files?

    Put the functions in a separate javascript file, add ".pragma library" at the beginning of the file and import that file into each of the files.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    Yonetici (20th July 2012)

  4. #3
    Join Date
    Jul 2012
    Posts
    26
    Thanks
    3
    Platforms
    Windows

    Default Re: How to connect functions of QML files?

    Quote Originally Posted by wysota View Post
    Put the functions in a separate javascript file, add ".pragma library" at the beginning of the file and import that file into each of the files.
    ok, I will do

Similar Threads

  1. Replies: 1
    Last Post: 28th January 2012, 12:35
  2. Replies: 2
    Last Post: 9th May 2011, 10:38
  3. Replies: 3
    Last Post: 13th February 2011, 17:53
  4. Replies: 16
    Last Post: 16th February 2010, 13:17
  5. Replies: 4
    Last Post: 10th November 2006, 15:38

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.