Hi,

I’m trying to horizontally center a rectangle in a window. This is my code:
Qt Code:
  1. Window
  2. {
  3. visible: true
  4. width: 400
  5. height: 600
  6.  
  7. Rectangle
  8. {
  9. id: rectLayout
  10. anchors.fill: parent
  11.  
  12. Rectangle
  13. {
  14. width: 90
  15. height: 25
  16. anchors.top: rectLayout.top
  17. anchors.left: rectLayout.left
  18. anchorrs.topMargin: 5
  19. anchors.horizontalCenter: rectLayout.horizontalCenter
  20. }
  21. }
  22. }
To copy to clipboard, switch view to plain text mode 
The wanted effect is a rectangle with top margin to the window of 5px and horizontally centered with a total width of 90 and height of 25 pixels.

The problem is, that using anchors.horizontalCenter: rectLayout.horizontalCenter results in streching the rectangle to the whole width of the window…

Does anybody know how I can avoid this effect?

Thank you in anticipation :-)