Advertisement
Guest User

Untitled

a guest
May 11th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 2.67 KB | None | 0 0
  1. import QtQuick 2.6
  2. import QtQuick.Window 2.2
  3. import QtQuick.Layouts 1.1
  4. import QtQuick.Controls 1.3
  5.  
  6. Window {
  7.     visible: true
  8.     width: 640
  9.     height: 480
  10.     title: qsTr("List food")
  11.     color: "lightgrey"
  12.  
  13.  
  14.     ListView{
  15.         model: listmod
  16.         id: listId
  17.         property int selected_id: -1
  18.         width: parent.width
  19.         height: parent.height - 100
  20.  
  21.         delegate: Rectangle{
  22.             width: parent.width
  23.             anchors.left: parent.left
  24.             height: 100
  25.             clip: true
  26.             Rectangle{
  27.                 anchors.fill: parent
  28.                 anchors.margins: 5
  29.                 color: (listId.selected_id == index)  ? "red" : ((index % 2 == 0) ? "lightsteelblue" : "lightskyblue")
  30.                 //border.color: (listId.selected_id == index)  ? "black" : ((index % 2 == 0) ? "lightsteelblue" : "lightskyblue")
  31.                 ColumnLayout{
  32.                     anchors.leftMargin: 20
  33.                     Label{
  34.                         text: name
  35.                     }
  36.                     Label{
  37.                         text: "Kalória: "+calories+ " kcal"
  38.  
  39.                     }
  40.                     Label{
  41.                         text: "Szénhidrát: "+carb+ " g"
  42.  
  43.                     }
  44.                     Label{
  45.                         text: "Fehérje: "+protein+ " g"
  46.  
  47.                     }
  48.                     Label{
  49.                         text: "Zsír: "+fat+ " g"
  50.  
  51.                     }
  52.                 }
  53.             }
  54.  
  55.             MouseArea{
  56.                 width: parent.width
  57.                 height: parent.height
  58.                 onClicked: {
  59.                     seltextid.text = name + "\n" + "Kalória: "+calories+ " kcal" + "\n" + "Szénhidrát: "+carb+ " g" + "\n" + "Fehérje: "+protein+ " g" + "\n" + "Zsír: "+fat+ " g" +"\n"
  60.                     listId.selected_id = index
  61.                 }
  62.             }
  63.         }
  64.     }
  65.  
  66.     Rectangle{
  67.         id: rect
  68.         width: parent.width/2
  69.         height: 80
  70.         anchors.bottom: parent.bottom
  71.         anchors.left: parent.left
  72.         color: "yellow"
  73.  
  74.         TextArea{
  75.              id: seltextid
  76.              anchors.top: parent.top
  77.              backgroundVisible: false
  78.              width: parent.width
  79.              height: parent.height
  80.         }
  81.     }
  82.     Rectangle{
  83.         id: rectin
  84.         width: parent.width/2
  85.         height: 80
  86.         anchors.right: parent.right
  87.         anchors.bottom: parent.bottom
  88.         color: "orange"
  89.  
  90.         TextInput {
  91.           id: inputText
  92.           text: "Paprika"
  93.           onAccepted: {
  94.               manager.textInputSlot(inputText.text);
  95.           }
  96.         }
  97.     }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement