Results 1 to 15 of 15

Thread: failed to assigned loader source component

  1. #1
    Join Date
    Oct 2014
    Posts
    104
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default failed to assigned loader source component

    Hi Qt Experts,

    I have a model with page element that will determine which component to be displayed in the delegate using loader.
    I encountered this error "Unable to assign QString to QQmlComponent*"
    Is my implementation correct? Is there any efficient way to do it?
    And also, how to change the page after swiping the last element?
    Btw, there is a main loader that called the Wizard.qml. Should I just change the main loader source?

    Please advise. Thanks

    Here's my code:

    Qt Code:
    1. //Wizard.qml
    2. Item {
    3. ListModel {
    4. id: wizardModel
    5. ListElement {
    6. page: "page1"
    7. }
    8. ListElement {
    9. page: "page2"
    10. }
    11. ListElement {
    12. page: "page3"
    13. }
    14. }
    15.  
    16. ListView {
    17. anchors.fill: parent
    18. focus: true
    19. highlightRangeMode: ListView.StrictlyEnforceRange
    20. orientation: ListView.Horizontal
    21. snapMode: ListView.SnapOneItem
    22. model: wizardModel
    23. delegate: WizardDelegate {}
    24. }
    25. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. //WizardDelegate.qml
    2. Item
    3. {
    4. id: root
    5. width: ListView.view.width; height: ListView.view.height
    6.  
    7. Rectangle
    8. {
    9. id: header
    10. height: 100
    11. Layout.fillWidth: true
    12. color: "#00000000"
    13. clip: true
    14. anchors {
    15. top: parent.top
    16. left: parent.left
    17. right: parent.right
    18. }
    19.  
    20. Text
    21. {
    22. id: title
    23. text: "Welcome"
    24. color: "#FFFFFF"
    25. wrapMode: Text.WordWrap
    26. anchors.centerIn: parent
    27. }
    28. }
    29.  
    30. Rectangle
    31. {
    32. id: body
    33. color: "#00000000"
    34. clip: true
    35. width: parent.width
    36. height: footer.y - y
    37. anchors {
    38. top: header.bottom
    39. topMargin: 30
    40. left: parent.left
    41. right: parent.right
    42. }
    43.  
    44. Loader {
    45. id: loader
    46. sourceComponent: model.page
    47. anchors.fill: parent
    48. }
    49.  
    50. Component {
    51. id: page1
    52. Image
    53. {
    54. id: image
    55. source: "../images/icon1.png"
    56. }
    57. }
    58.  
    59. Component {
    60. id: page2
    61. Image
    62. {
    63. id: image
    64. source: "../images/icon2.png"
    65. }
    66. }
    67.  
    68. Component {
    69. id: page3
    70. Image
    71. {
    72. id: image
    73. source: "../images/icon3.png"
    74. }
    75. }
    76. }
    77.  
    78. Rectangle
    79. {
    80. id: footer
    81. Layout.fillWidth: true
    82. color: "#00000000"
    83. height: 100
    84. anchors {
    85. left: parent.left
    86. right: parent.right
    87. bottom: parent.bottom
    88. }
    89.  
    90. CustomCheckBox
    91. {
    92. id: checkbox
    93. text: "Do not show this message again."
    94. anchors {
    95. left: parent.left
    96. right: parent.right
    97. }
    98. }
    99. }
    100. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by joko; 8th January 2015 at 15:28.

  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: failed to assigned loader source component

    model.page is a string, Loader.sourceComponent wants a Component.

    The property you are most likely looking for is Loader.source, each "page" containing the name of a QML file containing that page

    Cheers,
    _

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

    joko (9th January 2015)

  4. #3
    Join Date
    Oct 2014
    Posts
    104
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: failed to assigned loader source component

    Quote Originally Posted by anda_skoa View Post
    model.page is a string, Loader.sourceComponent wants a Component.

    The property you are most likely looking for is Loader.source, each "page" containing the name of a QML file containing that page

    Cheers,
    _
    Thanks for your quick response, I just use loader.source then.

    Any advise on how to change to page when it reach the last item on listview? Thanks

  5. #4
    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: failed to assigned loader source component

    Quote Originally Posted by joko View Post
    Any advise on how to change to page when it reach the last item on listview? Thanks
    What is your requirement?
    What should happen when the last item becomes visible?

    Cheers,
    _

  6. #5
    Join Date
    Oct 2014
    Posts
    104
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: failed to assigned loader source component

    Quote Originally Posted by anda_skoa View Post
    What is your requirement?
    What should happen when the last item becomes visible?

    Cheers,
    _
    I would like to know the signal used by either Listview or Flickable to determine if the last element was flicked, if there's an available signal.
    As mentioned i have a main loader that loads the Wizard.qml, I wanted to display another page once the last item was flicked/swiped to right.
    I would like to change the main loader source so that the new page will display.

    Thanks.

  7. #6
    Join Date
    Oct 2014
    Posts
    104
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: failed to assigned loader source component

    I have found this signal onMovementStarted to trigger the changing of loader source.
    However I need to know if the user swipe to right before it changes the source.
    Is this a correct way to trigger the change of page or there's a better option.
    Any suggestions? Thanks

    Qt Code:
    1. ListView {
    2. id: wizardList
    3. anchors.fill: parent
    4. focus: true
    5. highlightRangeMode: ListView.StrictlyEnforceRange
    6. orientation: ListView.Horizontal
    7. snapMode: ListView.SnapOneItem
    8. model:
    9. ListModel {
    10. ListElement {
    11. page: "Wizard1.qml"
    12. }
    13. ListElement {
    14. page: "Wizard2.qml"
    15. }
    16. ListElement {
    17. page: "Wizard3.qml"
    18. }
    19. }
    20. delegate: WizardDelegate {}
    21. onMovementStarted: {
    22. if (wizardList.currentIndex == 2) { // i need to include in the condition to check if the swipe direction is to the right
    23. mainLoader.source = "Main.qml"
    24. }
    25.  
    26. }
    27. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by joko; 9th January 2015 at 15:07.

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: failed to assigned loader source component

    Why don't you just add Main.qml to your model?
    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.


  9. #8
    Join Date
    Oct 2014
    Posts
    104
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: failed to assigned loader source component

    Quote Originally Posted by wysota View Post
    Why don't you just add Main.qml to your model?
    Because the Main page is completely different from the wizard pages and i don't want to go back to the wizard pages once it reaches the Main page.
    Is there a way to check the swipe movement? I still trying to use the contentX, if that is possible.

    Thanks

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: failed to assigned loader source component

    I completely fail to understand why you want to act on a flick. Whatever you are trying to do, I don't think the approach you have taken is a proper one. Maybe you could restate your problem in a descriptive way and we'll try to suggest an approach to solve it.
    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.


  11. #10
    Join Date
    Oct 2014
    Posts
    104
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: failed to assigned loader source component

    Quote Originally Posted by wysota View Post
    I completely fail to understand why you want to act on a flick. Whatever you are trying to do, I don't think the approach you have taken is a proper one. Maybe you could restate your problem in a descriptive way and we'll try to suggest an approach to solve it.
    Thank you for your response.

    I have a main loader which loaded the wizard page with list view of wizard pages.
    I used list view so that the user can flick on those pages back and forth.
    At the last item, when the user flick to the right, it will exit on the list view (wizard) and will display the main page.
    Once on main page, the user cannot go back to the wizard anymore.

    Let me know if you have further questions on my implementation.

    Thanks a lot for your time.

  12. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: failed to assigned loader source component

    Quote Originally Posted by joko View Post
    loaded the wizard page with list view of wizard pages.
    I don't understand that. Wizard page with a view of wizard pages?
    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.


  13. #12
    Join Date
    Oct 2014
    Posts
    104
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: failed to assigned loader source component

    Quote Originally Posted by wysota View Post
    I don't understand that. Wizard page with a view of wizard pages?
    The Wizard qml page, where I put the Listview using the ListModel of pages.

    Here is my Wizard qml page.

    Qt Code:
    1. ListView {
    2. id: wizardList
    3. anchors.fill: parent
    4. focus: true
    5. highlightRangeMode: ListView.StrictlyEnforceRange
    6. orientation: ListView.Horizontal
    7. snapMode: ListView.SnapOneItem
    8. model:
    9. ListModel {
    10. ListElement {
    11. page: "Wizard1.qml"
    12. }
    13. ListElement {
    14. page: "Wizard2.qml"
    15. }
    16. ListElement {
    17. page: "Wizard3.qml"
    18. }
    19. }
    20. delegate: WizardDelegate {}
    21. }
    To copy to clipboard, switch view to plain text mode 

  14. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: failed to assigned loader source component

    Let's summarize -- you have a number of wizards, each composed of a number of wizard pages. You want to advance the wizard by flicking until you reach the last page of the wizard and if you flick again you should be brought to the main page where you can do some other actions (e.g. choose another wizard). Is that correct?
    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.


  15. #14
    Join Date
    Oct 2014
    Posts
    104
    Thanks
    16
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: failed to assigned loader source component

    Quote Originally Posted by wysota View Post
    Let's summarize -- you have a number of wizards, each composed of a number of wizard pages. You want to advance the wizard by flicking until you reach the last page of the wizard and if you flick again you should be brought to the main page where you can do some other actions (e.g. choose another wizard). Is that correct?
    Basically, I only have 1 wizard, the list elements on List Model are just pages of the wizard.
    Yes, you are correct, after reaching the last page, I should be brought to main page.

  16. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: failed to assigned loader source component

    In that case in my opinion pages of the wizard should be handled on the same level as remaining pages of the application (i.e. without a separate list view).
    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.


Similar Threads

  1. update Loader source
    By codeman in forum Qt Quick
    Replies: 1
    Last Post: 25th July 2014, 16:21
  2. Geotechnical engineer and I have been assigned
    By Jackson Kulakowski in forum Qt Programming
    Replies: 1
    Last Post: 2nd June 2013, 18:22
  3. Replies: 2
    Last Post: 25th March 2013, 18:06
  4. Replies: 1
    Last Post: 23rd February 2013, 17:05
  5. Replies: 0
    Last Post: 23rd November 2011, 18:56

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.