Results 1 to 2 of 2

Thread: Loader - propery alias on loaded components

  1. #1
    Join Date
    Nov 2014
    Posts
    33
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Loader - propery alias on loaded components

    I would like to load a Map component in background with a Loader only when the visible Map property is true. Moreover, I need to access the Map center property. How can create a property alias to the Map center property when the Map is loaded with a Loader?

    Map2.qml:
    Qt Code:
    1. import QtQuick 2.0
    2. import QtQuick.Controls 1.3
    3. import QtLocation 5.5
    4. import QtPositioning 5.3
    5.  
    6. Item {
    7. id: root
    8.  
    9. property alias center: ?????
    10.  
    11. Loader {
    12. anchors.fill: parent
    13. id: mapLoader
    14. active: root.visible
    15. sourceComponent: cMap
    16. }
    17. Component {
    18. id: cMap
    19. Item {
    20. anchors.fill: parent
    21. Slider {
    22. id: zoomSlider;
    23. z: map.z + 3
    24. minimumValue: map.minimumZoomLevel;
    25. maximumValue: map.maximumZoomLevel;
    26. anchors.margins: 10
    27. anchors.bottom: parent.bottom
    28. anchors.top: parent.top
    29. anchors.right: parent.right
    30. orientation : Qt.Vertical
    31. value: map.zoomLevel
    32. onValueChanged: {
    33. map.zoomLevel = value
    34. }
    35. }
    36. Map {
    37. id: map
    38. anchors.fill: parent
    39. plugin: osmPlugin
    40. zoomLevel: 7
    41. }
    42. Plugin {
    43. id: osmPlugin
    44. name: "osm"
    45. }
    46.  
    47. }
    48. }
    49. }
    To copy to clipboard, switch view to plain text mode 

    Using on another qml:
    ...
    Qt Code:
    1. Map2 {
    2. visible: cbMap.checked
    3. center: QtPositioning.coordinate(1.759767, 1.864124)
    4. }
    To copy to clipboard, switch view to plain text mode 
    ...

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,419
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Loader - propery alias on loaded components

    I don't think that is possible, the alias would "dangling" if the Loader's item is not there.

    If you don't need the center property for reading, you could simply make it a normal property (instead of an alias) and then bind the Map's center property to it.

    Cheers,
    _

Similar Threads

  1. Cant access alias from Item
    By guidupas in forum Qt Quick
    Replies: 9
    Last Post: 11th June 2015, 16:15
  2. Replies: 0
    Last Post: 27th November 2014, 10:24
  3. Replies: 9
    Last Post: 16th August 2014, 14:33
  4. QGraphicsView::centerOn not working propery in 4.6
    By deca5423 in forum Qt Programming
    Replies: 4
    Last Post: 28th January 2010, 00:16
  5. Propery capable QGraphicsTextItem
    By Gopala Krishna in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2007, 18:26

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.