Forums

OverviewFelgo 2 Support (Qt 5) › Custom delegate in ListPag

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #16757

    Wojciech

    I have problem with passing data from model (it is simple array as in PropertyCross example) to custom delegate:

      delegate: Component {
          AppImage {
              source: item.image 
              width: parent.width/2
              height: 100
              fillMode:Image.PreserveAspectFit; clip:true
          }
      }

    item is not visible, image alone naither. How should I read values from array model?

    Regards,
    Wojciech

    #16759

    Günther
    Felgo Team

    Hi!

    The item property is only available with the SimpleRow delegate (we added it to make working with the model easier). For custom delegates, the usable identifier to access an array-model is modelData:

    model: [
    { image: "<image-path>" }
    ]
    delegate: Component {
      AppImage {
        source: modelData.image
        // ...
      }
    }

    Best,
    Günther

    #16762

    Wojciech

    Ok, thank you. Could you advice me how to make delegates to layout in two columns? Now the delegate components renders nice, but in rows: one under one, despite that I set their width for less than parent.width/2.

    I would like to show it in 2 (or more) colums as ‘float: left;’ layout for divs in html  – is it possible?

    #16763

    Günther
    Felgo Team

    Hi!

    It depends on what you are using to render your delegates. There are several QML types available for your layouts.

    For the AppListView, it is possible to define the list as horizontal or vertical with the AppListView::orientation property. You can also have look at other layout types like Row, Column or GridLayout.

    To dynamically fill e.g. a Row with Items based on a model/delegate, you can add a Repeater as a child, which in turn fills the row with dynamically created objects then.

    For more details about creating layouts in QML and available components, please have a look at the Qt docs and Felgo docs. You can also have a look at the code of all our app demos and examples to see how things are implemented there.

    Cheers,
    Günther

Viewing 4 posts - 1 through 4 (of 4 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support