Advertisement
tham7777

Untitled

Feb 25th, 2020
2,819
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 1.38 KB | None | 0 0
  1. import Felgo 3.0
  2. import QtQuick 2.0
  3. import QtQuick.Controls 2.4 as QQ2
  4.  
  5. App {
  6.     id: app
  7.     // You get free licenseKeys from https://felgo.com/licenseKey
  8.     // With a licenseKey you can:
  9.     //  * Publish your games & apps for the app stores
  10.     //  * Remove the Felgo Splash Screen or set a custom one (available with the Pro Licenses)
  11.     //  * Add plugins to monetize, analyze & improve your apps (available with the Pro Licenses)
  12.     //licenseKey: ""
  13.  
  14.     function generateRandomColor()
  15.     {
  16.         var randomColor = "#"
  17.         for(var i = 0; i !== 3; ++i){
  18.             randomColor = randomColor + (Math.floor(Math.random() * 255)).toString(16)
  19.         }
  20.         console.log(randomColor)
  21.         return randomColor
  22.     }
  23.  
  24.     Rectangle{
  25.         id: rect
  26.  
  27.         width: parent.width
  28.         height: dp(40)
  29.         color: "red"
  30.     }
  31.  
  32.     ListModel{
  33.         id: listModel
  34.     }
  35.  
  36.     Component.onCompleted: {
  37.         for(var i = 0; i !== 50; ++i){
  38.             listModel.append({"colorText": generateRandomColor(), "index": i})
  39.         }
  40.     }
  41.  
  42.     ListPage{
  43.         anchors.top: rect.bottom
  44.         model: listModel
  45.         delegate: Rectangle{
  46.             height: dp(30)
  47.             width: parent.width
  48.             color: colorText
  49.  
  50.             Text{
  51.                 anchors.fill: parent
  52.                 text: index
  53.             }
  54.         }
  55.     }    
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement