Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    [Solved] Issue with delegate

    QML and Qt Quick
    3
    7
    2672
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Merinas last edited by

      Hi,

      I've wrote a module base on a delegate example "Accessing Views and Models from Delegates" from "here":http://doc.qt.nokia.com/4.7-snapshot/qdeclarativemodels.html . Basically I have separate  model, view and delegate into three qml file. 
      
      And I use them into a main qml file by calling the view module. It work fine. But if I use a .bat file to launch my main qml file the delegate can't access the model. I need a .bat to open the qmlviewer with -opengl option.
      
      "Here":http://dl.free.fr/nfP6HLyJ7 you can find a archive to test by yourself, try launching main.qml and the bat file. 
      

      Thanks

      1 Reply Last reply Reply Quote 0
      • A
        andre last edited by

        Sounds like an issue with paths that are set if you run from the Qt Creator context, but not if you run from your .bat file.

        1 Reply Last reply Reply Quote 0
        • M
          Merinas last edited by

          I never launch from qt creator. I have assign .qml to qmlviewer. So i double click on a qml file, but here I need -opengl. Anyway for me it look like a scope mistake. But I don't know what I should do.

          Have tested my issue with the given files ?

          1 Reply Last reply Reply Quote 0
          • B
            baysmith last edited by

            Change view.qml to View.qml

            bq. Any snippet of QML code can become a component, by placing the code in a file "<Name>.qml" where <Name> is the new component name, beginning with an uppercase letter.
            from http://doc.qt.nokia.com/4.7/qml-extending-types.html

            Nokia Certified Qt Specialist.

            1 Reply Last reply Reply Quote 0
            • M
              Merinas last edited by

              Thanks for your answer but I made this mistake while i was trying to reproduce the bug, sorry for that.

              In fact, i don't use a listview but a personal view like this one :
              PersonnalView.qml
              @import QtQuick 1.0

              Item {
              property alias model: rept.model
              property Component delegate:Component { Rectangle{} }

              Column {
              Repeater
              {
              id:rept
              Loader
              {
              sourceComponent: delegate;
              }
              }
              }
              }@

              Used that way in View.qml
              @import QtQuick 1.0

              PersonnalView{
              width:300
              height:300

              model:Model{}
              delegate:Delegate{}

              }@

              And again used in a main qml file I still got the same scope bug.
              I've uploaded "here":http://dl.free.fr/kr26FMm75 a new version of my code which still doesn't work if launched by a .bat but work if directly launched by main file.

              Thanks

              1 Reply Last reply Reply Quote 0
              • B
                baysmith last edited by

                I don't get a different behavior if launching by a .bat or directly. However, the example doesn't work because the Repeater's model data doesn't get automatically bound to the Loader's source component. The model data can be passed through the Loader manually with the following changes.

                Modified PersonnalView.qml
                @
                import QtQuick 1.0

                Item {
                property alias model: rept.model
                property Component delegate:Component { Rectangle{} }

                Column {
                    Repeater {
                        id:rept
                        Loader {
                            property string name: rept.model.get(index).name
                            property string cost: rept.model.get(index).cost
                            sourceComponent: delegate;
                        }
                    }
                }
                

                }
                @

                Nokia Certified Qt Specialist.

                1 Reply Last reply Reply Quote 0
                • M
                  Merinas last edited by

                  Thanks that work great, but I still need to adapt my view to my model which doesn't seems quite well. I guess that works with ListView, GridView ... Because they aren't made of qml file but c++ plugin...

                  This will let an open debate I think, Because personal view might be something user want to do.

                  Thanks again for your help.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post