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. Dynamically allocating images
Forum Updated to NodeBB v4.3 + New Features

Dynamically allocating images

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 831 Views 1 Watching
  • 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.
  • D Offline
    D Offline
    dstudentx
    wrote on last edited by
    #1

    My project is starting to get a little out of hand in terms of the amount of times I have to create images and call functions. for example, I have 5 identical images in a row

    @
    Image {id: movie_list1; x: -342; y: 502; width: 100; height: 100; ....
    Image {id: movie_list2; x: -342; y: 502; width: 100; height: 100; ....
    Image {id: movie_list3; x: -342; y: 502; width: 100; height: 100; ....
    Image {id: movie_list4; x: -342; y: 502; width: 100; height: 100; ....
    Image {id: movie_list5; x: -342; y: 502; width: 100; height: 100; ...
    @

    Can I just make it something like
    @
    for i to 5
    Image {id: movie_list; x: -342; y: 502; width: 100; height: 100;
    @

    1 Reply Last reply
    0
    • S Offline
      S Offline
      stereomatching
      wrote on last edited by
      #2

      Try repeater, ListView or other view according to your need

      //pseudo codes
      @
      ListModel{
      id: photoModel

      ListElement{name: "movie_list1"}
      //....and so on
      

      }

      ColumnLayout{
      Repeater {
      model: photoModel
      Image {
      width: 100; height: 40
      x: -342; y: 502
      source: name
      }
      }
      }
      @

      or a more simple one
      @
      property var names : {"movie1", "movie2"}

      ColumnLayout{
      Repeater {
      model: names
      Image {
      width: 100; height: 40
      x: -342; y: 502
      source: modelData
      }
      }
      }
      @

      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