# Anclaje de controles

* anchors.alignWhenCentered
* anchors.baseline
* anchors.baselineOffset
* anchors.bottom
* anchors.bottomMargin
* anchors.centerIn
* anchors.fill
* anchors.horizontalCenter
* anchors.horizontalCenterOffset
* anchors.left
* anchors.leftMargin
* anchors.margins
* anchors.right
* anchors.rightMargin
* anchors.top
* anchors.topMargin
* anchors.verticalCenter
* anchors.verticalCenterOffset

```
import QtQuick 2.15
import QtQuick.Controls 2.15
import org.mauikit.controls 1.3 as Maui

Maui.ApplicationWindow
{
    id: root

    Maui.Page {
        anchors.fill: parent

        showCSDControls: true

        Rectangle {
            id: rect1

            anchors.right: parent.right
            anchors.top: parent.top
            anchors.margins: 100
            width: 100
            height: 100
            color: "deeppink"
            radius: 4

            Label {
                anchors.centerIn: parent
                text: "rect1"
            }
        }

        Rectangle {
            id: rect2

            anchors.centerIn: parent

            width: 100
            height: 100
            color: "mediumspringgreen"
            radius: 4

            Label {
                anchors.centerIn: parent
                text: "rect2"
            }
        }
    }
}
```

## Casos de anclaje de rect2.

**Anclaje 1.**

```
anchors.centerIn: parent
```

<figure><img src="https://3899745996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FED1v8xhNFPWKlgOCuryr%2Fuploads%2FGG8SHAKlNVlBz9WQUcCv%2FUtil-Anclaje-01.jpg?alt=media&#x26;token=5143a971-e131-40f7-9052-a31a20486e80" alt=""><figcaption></figcaption></figure>

**Anclaje 2.**

```
anchors.fill: parent
```

<figure><img src="https://3899745996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FED1v8xhNFPWKlgOCuryr%2Fuploads%2FpMqFA8EmnceikYeNZ2D5%2FUtil-Anclaje-02.jpg?alt=media&#x26;token=11452e38-f943-45e6-a139-529fd32c4e5a" alt=""><figcaption></figcaption></figure>

**Anclaje 3.**

```
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
```

<figure><img src="https://3899745996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FED1v8xhNFPWKlgOCuryr%2Fuploads%2FNGmcy35zhGOqHiiOdRRT%2FUtil-Anclaje-03.jpg?alt=media&#x26;token=54e6720e-09a8-470d-86bd-0a04f8afa9ee" alt=""><figcaption></figcaption></figure>

**Anclaje 4.**

```
anchors.top: rect1.bottom
anchors.right: rect1.left
```

<figure><img src="https://3899745996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FED1v8xhNFPWKlgOCuryr%2Fuploads%2F3NY8TWjnOcCiCzN9Kl3z%2FUtil-Anclaje-04.jpg?alt=media&#x26;token=525d5fe4-6660-4545-978b-64828c83e832" alt=""><figcaption></figcaption></figure>

**Anclaje 5.**

anchors.fill: rect1

<figure><img src="https://3899745996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FED1v8xhNFPWKlgOCuryr%2Fuploads%2FyoUYRceu1J3NhVITvBi4%2FUtil-Anclaje-05.jpg?alt=media&#x26;token=e2c9fab3-4fbb-4222-b1e3-11bb303b259a" alt=""><figcaption></figcaption></figure>

## Orden z.

Define la posición por encima o por debajo de un control sobre los demás controles. Para el caso de "Anclaje 2" si se establece "z: 1" en rect1, éste será establecido encima de rect2.

```
import QtQuick 2.15
import QtQuick.Controls 2.15
import org.mauikit.controls 1.3 as Maui

Maui.ApplicationWindow
{
    id: root

    Maui.Page {
        anchors.fill: parent

        showCSDControls: true

        Rectangle {
            id: rect1

            anchors.right: parent.right
            anchors.top: parent.top
            anchors.margins: 100
            width: 100
            height: 100
            color: "deeppink"
            radius: 4
            z: 1

            Label {
                anchors.centerIn: parent
                text: "rect1"
            }
        }

        Rectangle {
            id: rect2

            anchors.fill: parent

            width: 100
            height: 100
            color: "mediumspringgreen"
            radius: 4

            Label {
                anchors.centerIn: parent
                text: "rect2"
            }
        }
    }
}
```

<figure><img src="https://3899745996-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FED1v8xhNFPWKlgOCuryr%2Fuploads%2FzPOoMkkuiuWJfSiar4jR%2FUtil-Anclaje-02-z1.jpg?alt=media&#x26;token=24070065-e101-486d-8e0c-28e26e12fa35" alt=""><figcaption></figcaption></figure>
