Advertisement
Guest User

Untitled

a guest
Dec 20th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 1.69 KB | None | 0 0
  1. import QtQuick 2.6
  2. import QtQuick.Window 2.2
  3. import QtMultimedia 5.9
  4. import QtWebEngine 1.1
  5. import QtWebView 1.1
  6.  
  7. Window {
  8.     id: window
  9.  
  10.     visible: true
  11.     title: "Window"
  12.  
  13.     minimumWidth: 720
  14.     minimumHeight: 480
  15.     Column {
  16.         Repeater {
  17.             model: [
  18.                 "<l3dx> GrecKo: to be more specific I want to set the width of the Text to be some % of parent.width so that elide will truncate the text for me if it's too big. But I don't want the width to be that wide unless it is necessary. The reason for this is that I want to show a \"badge\" next to the text in some cases, and I want the badge to be placed close to the text",
  19.                 "use contentWidth to position the badge"
  20.             ]
  21.             delegate: Row {
  22.                 spacing: 20
  23.                 Item { //textWrapper
  24.                     anchors.verticalCenter: parent.verticalCenter
  25.                     width: text.contentWidth
  26.                     height: text.contentHeight
  27.                     Text {
  28.                         id: text
  29.                         width: window.width * 0.5
  30.                         elide: Text.ElideRight
  31.                         text: modelData
  32.                     }
  33.                 }
  34.                 Rectangle { // badge
  35.                     anchors.verticalCenter: parent.verticalCenter
  36.                     width: 30
  37.                     height: width
  38.                     radius: width / 2
  39.                     color: "orange"
  40.                     Text {
  41.                         anchors.centerIn: parent
  42.                         text: index
  43.                         color: "white"
  44.                     }
  45.                 }
  46.             }
  47.         }
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement