Advertisement
ACClMRS

Anchor em QML

Aug 25th, 2017
2,537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 1.76 KB | None | 0 0
  1. import QtQuick 2.7
  2. import QtQuick.Controls 2.0
  3. import QtQuick.Layouts 1.3
  4.  
  5. ApplicationWindow {
  6.     visible: true
  7.     width: 640
  8.     height: 480
  9.     title: qsTr("Hello World")
  10.  
  11.  
  12.     Rectangle {
  13.         id: rec
  14.         width: 250
  15.         height: 250
  16.         color: "gray"
  17.         anchors.centerIn: parent
  18.     }
  19.  
  20.  
  21.     Button {
  22.         id: oi
  23.         text: "oi"
  24.         anchors.right: rec.left // Direita do botão oi está ancorada a esquerda de rec
  25.         anchors.bottom: rec.top // Base do botão oi está ancorada ao topo de rec
  26.     }
  27.  
  28.     Button {
  29.         id: oi2
  30.         text: "oi2"
  31.         anchors.right: rec.left // Direita do botão oi2 está ancorada a esquerda de rec
  32.         anchors.verticalCenter: rec.verticalCenter  // VerticalCenter do botão oi2 está ancorada a verticalCenter de rec
  33.     }
  34.  
  35.     Button {
  36.         id: oi3
  37.         text: "oi3"
  38.         anchors.right: rec.left
  39.         anchors.top: rec.bottom
  40.     }
  41.  
  42.     Button {
  43.         id: oi4
  44.         text: "oi4"
  45.         anchors.top: rec.bottom // Topo do botão oi4 está ancorada a base de rec
  46.         anchors.horizontalCenter: rec.horizontalCenter // horizontalCenter do botão oi4 está ancorada em horizontalCenter de rec
  47.     }
  48.  
  49.  
  50.     Button {
  51.         id: oi5
  52.         text: "oi5"
  53.         anchors.left: rec.right
  54.         anchors.top: rec.bottom
  55.     }
  56.  
  57.  
  58.  
  59.     Button {
  60.         id: oi6
  61.         text: "oi6"
  62.         anchors.left: rec.right
  63.         anchors.verticalCenter: rec.verticalCenter
  64.     }
  65.  
  66.     Button {
  67.         id: oi7
  68.         text: "oi7"
  69.         anchors.left: rec.right
  70.         anchors.bottom: rec.top
  71.     }
  72.  
  73.  
  74.     Button {
  75.         id: oi8
  76.         text: "oi8"
  77.         anchors.bottom: rec.top
  78.         anchors.horizontalCenter: rec.horizontalCenter
  79.     }
  80.  
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement