Results 1 to 3 of 3

Thread: Forcing desired space between two rectangles in GridLayout

  1. #1
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Forcing desired space between two rectangles in GridLayout

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Forcing desired space between two rectangles in GridLayout

    There is no content in any of the columns between the 0 and 11, so these columns have width 0.

    If you need those columns to have a certain width, add an appropriately sized Item into any row.

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    TheIndependentAquarius (3rd May 2016)

  4. #3
    Join Date
    Apr 2011
    Posts
    231
    Thanks
    141
    Thanked 6 Times in 5 Posts

    Default Re: Forcing desired space between two rectangles in GridLayout

    Thankful to you, again.

Similar Threads

  1. How to add lines to desired frame only
    By athulms in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2011, 08:43
  2. How to add space b/w column and rows of gridlayout.
    By Niamita in forum Qt Programming
    Replies: 3
    Last Post: 8th July 2011, 07:55
  3. Replies: 1
    Last Post: 26th July 2009, 15:08
  4. How to drop space in GridLayout ?
    By jackm in forum Qt Tools
    Replies: 2
    Last Post: 3rd October 2008, 03:06
  5. linking user space and kernel space programs with qmake
    By zielchri in forum Qt Programming
    Replies: 9
    Last Post: 8th March 2006, 23:11

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.