Qt Code:
  1. import QtQuick 2.4
  2. import QtQuick.Window 2.2
  3. import QtQuick.Layouts 1.1 // GridLayout
  4.  
  5. Window
  6. {
  7. visible: true
  8.  
  9. height: 700; width: 1000
  10.  
  11. GridLayout
  12. {
  13. id: gridLayout
  14. rows: 15;
  15. columns: 15;
  16. rowSpacing: 0; columnSpacing: 0
  17.  
  18. property int secondScreenOptionsOpacity: 0
  19.  
  20. property int hmmiButtonRow: 0
  21. property int hmmiButtonCol: 0
  22.  
  23. Rectangle
  24. {
  25. id: hmmi;
  26. Layout.row: gridLayout.hmmiButtonRow; Layout.column: gridLayout.hmmiButtonCol;
  27. height: 70; width: 150; color: "pink";
  28. Layout.alignment: Qt.AlignTop
  29. Text { text: "HMMI"; anchors.centerIn: parent }
  30. MouseArea {anchors.fill: parent; onClicked: mainScreenFunctionality.hmmiControlButton()}
  31. }
  32.  
  33. property int optionsButtonRow: 1
  34. property int optionsButtonCol: 0
  35.  
  36. Rectangle
  37. {
  38. id: optionsButton;
  39. Layout.row: gridLayout.optionsButtonRow; Layout.column: gridLayout.optionsButtonCol;
  40. height: 70; width: 150; color: "red"
  41. Layout.alignment: Qt.AlignBottom
  42. Text { text: "Options..."; anchors.centerIn: parent }
  43. MouseArea { anchors.fill: parent; onClicked: mainScreenFunctionality.optionsButton() }
  44. }
  45.  
  46. property int eulerWidgetRow: 1
  47. property int eulerWidgetCol: 11
  48.  
  49. Rectangle
  50. {
  51. id: eulerWidgetControl;
  52. Layout.row :gridLayout.eulerWidgetRow; Layout.column: gridLayout.eulerWidgetCol;
  53. height: 140; width: 140; color: "yellow"
  54. Layout.columnSpan: 2; Layout.rowSpan: 2
  55. Layout.alignment: Qt.AlignRight
  56. Text { text: "euler"; anchors.centerIn: parent }
  57. }
  58. }
  59. }
To copy to clipboard, switch view to plain text mode 

----------

Even though I have specified row 1 and column 11, see where the yellow rectangle is shown:

----------

There has to be empty space between the red and yellow rectangles.
How to put a rectangle in a particular row and column in GridLayout of QML?

Screenshot from 2016-05-02 12:03:56.jpg

----------


Adding `anchors.fill: parent` to GridLayout does the following:


----------

32.jpg