Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved] Issue with delegate
QtWS25 Last Chance

[Solved] Issue with delegate

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 3 Posters 3.1k Views
  • 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 Offline
    M Offline
    Merinas
    wrote on last edited by
    #1

    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
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      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
      0
      • M Offline
        M Offline
        Merinas
        wrote on last edited by
        #3

        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
        0
        • B Offline
          B Offline
          baysmith
          wrote on last edited by
          #4

          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
          0
          • M Offline
            M Offline
            Merinas
            wrote on last edited by
            #5

            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
            0
            • B Offline
              B Offline
              baysmith
              wrote on last edited by
              #6

              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
              0
              • M Offline
                M Offline
                Merinas
                wrote on last edited by
                #7

                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
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved