Results 1 to 2 of 2

Thread: QML Loader

  1. #1
    Join Date
    May 2011
    Posts
    81
    Thanks
    6
    Thanked 5 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default QML Loader

    In my mobile app, I want to load a 'default' page from my main.cpp:

    Qt Code:
    1. X.engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    To copy to clipboard, switch view to plain text mode 

    I use my main.qml as a 'container' for all the pages of my app. Right now, I have them all defined in main.qml:

    Qt Code:
    1. Rectangle {
    2. id: winRect
    3. visible: true
    4. anchors.right: parent.right
    5. anchors.left: parent.left
    6. anchors.top: header.bottom
    7. anchors.bottom: footer.top
    8. color: "black"
    9.  
    10. MainWin {
    11. id: mainWin
    12. anchors.fill: parent
    13. visible: false;
    14. z: 0;
    15. }
    16.  
    17. InfoWin {
    18. id: infoWin
    19. anchors.fill: parent
    20. visible: false;
    21. z: 0;
    22. }
    23.  
    24. SettingsWin {
    25. id: settingsWin
    26. anchors.fill: parent
    27. visible: false;
    28. z: 0;
    29. }
    30.  
    31. FileInfoWin {
    32. id: fileInfoWin
    33. anchors.fill: parent
    34. visible: false;
    35. z: 0;
    36. }
    37.  
    38. BusyWin {
    39. id: busyWin
    40. anchors.fill: parent
    41. visible: false;
    42. z: 0;
    43. }
    44.  
    45. ErrorWin {
    46. id: errorWin
    47. anchors.fill: parent
    48. visible: false;
    49. z: 0;
    50. }
    51. }
    To copy to clipboard, switch view to plain text mode 

    Then, later, via JavaScript, I 'show' the desired page by setting all 'visible' to false, then to true on the correct page. This all works fine...but causes a really slow startup time on iOS. I believe it is due to ALL my sub-pages being loaded at boot-time.

    My question is... How can I use a Loader to load each page on demand, but still be able to access the attributes of each page when it is not loaded? For instance, I have Speed and Heading that get updated on two different pages every second or so. If a page is not "loaded" by the Loader, how can I update it's attributes?

    IF that is not possible, then how can I detect when a page has fully loaded? As I understand it, the OnCompleted signal does not necessarily fire AFTER a component has been fully loaded.

    --Sam

  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: QML Loader

    The Loader has an onLoaded signal.

    You can also use a Binding element to create bindings to the loaded item's properties.
    Or you let the page content elements bind to the source directly.

    Cheers,
    _

Similar Threads

  1. Create a QML Loader in C++
    By mut in forum Qt Quick
    Replies: 1
    Last Post: 29th March 2016, 21:28
  2. loader issue
    By joko in forum Qt Quick
    Replies: 2
    Last Post: 24th October 2014, 17:31
  3. update Loader source
    By codeman in forum Qt Quick
    Replies: 1
    Last Post: 25th July 2014, 16:21
  4. Loader Problem
    By Yonetici in forum Qt Quick
    Replies: 1
    Last Post: 22nd July 2012, 16:11
  5. best way for a own animated loader?
    By janton in forum Newbie
    Replies: 2
    Last Post: 28th February 2012, 19:52

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.