IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

SplitView QML Type

Lays out items with a draggable splitter between each item.

This type was introduced in Qt 5.13.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

SplitView QML Type▲

  • Import Statement: import QtQuick.Controls 2.5

  • Since: Qt 5.13

  • Inherits: Control

  • Group: SplitView is part of qtquickcontrols2-containers, qtquickcontrols2-focusscopes

Detailed Description▲

https:// is a control that lays out items horizontally or vertically with a draggable splitter between each item.

https:// supports the following attached properties on items it manages:

  • SplitView.minimumWidth

  • SplitView.minimumHeight

  • SplitView.preferredWidth

  • SplitView.preferredHeight

  • SplitView.maximumWidth

  • SplitView.maximumHeight

  • SplitView.fillWidth (true for only one child)

  • SplitView.fillHeight (true for only one child)

In addition, each handle has the following read-only attached properties:

  • SplitHandle.hovered

  • SplitHandle.pressed

The preferred size of items in a https:// can be specified via https:// and https:// or SplitView.preferredWidth and SplitView.preferredHeight:

 
Sélectionnez
SplitView {
    anchors.fill: parent

    Item {
        SplitView.preferredWidth: 50
    }

    // ...
}

For a horizontal https://, it's not necessary to specify the preferred height of each item, as they will be resized to the height of the view. This applies in reverse for vertical views.

When a split handle is dragged, the SplitView.preferredWidth or SplitView.preferredHeight property is overwritten, depending on the https:// of the view.

To limit the size of items in a horizontal view, use the following properties:

 
Sélectionnez
SplitView {
    anchors.fill: parent

    Item {
        SplitView.minimumWidth: 25
        SplitView.preferredWidth: 50
        SplitView.maximumWidth: 100
    }

    // ...
}

To limit the size of items in a vertical view, use the following properties:

 
Sélectionnez
SplitView {
    anchors.fill: parent
    orientation: Qt.Vertical

    Item {
        SplitView.minimumHeight: 25
        SplitView.preferredHeight: 50
        SplitView.maximumHeight: 100
    }

    // ...
}

There will always be one item (the fill item) in the https:// that has SplitView.fillWidth set to true (or SplitView.fillHeight, if https:// is Qt.Vertical). This means that the item will get all leftover space when other items have been laid out. By default, the last visible child of the https:// will have this set, but it can be changed by explicitly setting fillWidth to true on another item.

A handle can belong to the item either on the left or top side, or on the right or bottom side:

  • If the fill item is to the right: the handle belongs to the left item.

  • If the fill item is on the left: the handle belongs to the right item.

To create a https:// with three items, and let the center item get superfluous space, one could do the following:

 
Sélectionnez
SplitView {
    anchors.fill: parent
    orientation: Qt.Horizontal

    Rectangle {
        implicitWidth: 200
        SplitView.maximumWidth: 400
        color: "lightblue"
        Label {
            text: "View 1"
            anchors.centerIn: parent
        }
    }
    Rectangle {
        id: centerItem
        SplitView.minimumWidth: 50
        SplitView.fillWidth: true
        color: "lightgray"
        Label {
            text: "View 2"
            anchors.centerIn: parent
        }
    }
    Rectangle {
        implicitWidth: 200
        color: "lightgreen"
        Label {
            text: "View 3"
            anchors.centerIn: parent
        }
    }
}

Serializing SplitView's State▲

The main purpose of https:// is to allow users to easily configure the size of various UI elements. In addition, the user's preferred sizes should be remembered across sessions. To achieve this, the values of the SplitView.preferredWidth and SplitView.preferredHeight properties can be serialized using the https://() and https://() functions:

 
Sélectionnez
import QtQuick.Controls 2.13
import Qt.labs.settings 1.0

ApplicationWindow {
    // ...

    Component.onCompleted: splitView.restoreState(settings.splitView)
    Component.onDestruction: settings.splitView = splitView.saveState()

    Settings {
        id: settings
        property var splitView
    }

    SplitView {
        id: splitView
        // ...
    }
}

Alternatively, the https://() and https://() functions of https:// can be used:

 
Sélectionnez
import QtQuick.Controls 2.13
import Qt.labs.settings 1.0

ApplicationWindow {
    // ...

    Component.onCompleted: splitView.restoreState(settings.value("ui/splitview"))
    Component.onDestruction: settings.setValue("ui/splitview", splitView.saveState())

    Settings {
        id: settings
    }

    SplitView {
        id: splitView
        // ...
    }
}

See Also▲

See also https://, https://, https://

Property Documentation▲

 

handle : Component▲

This property holds the handle component.

An instance of this component will be instantiated count - 1 times, as long as count is greater than than 1.

The following table explains how each handle will be resized depending on the orientation of the split view:

Orientation

Handle Width

Handle Height

Qt.Horizontal

implicitWidth

The https:// of the https://.

Qt.Vertical

The https:// of the https://.

implicitHeight

See Also▲

See also https://

orientation : enumeration▲

This property holds the orientation of the https://.

The orientation determines how the split items are laid out:

Possible values:

Constant

Description

Qt.Horizontal

The items are laid out horizontally (default).

Qt.Vertical

The items are laid out vertically.

[read-only] resizing : bool▲

This property is true when the user is resizing split items by dragging on the splitter handles.

Attached Property Documentation▲

 

SplitView.fillHeight : bool▲

This attached property controls whether the item takes the remaining space in the split view after all other items have been laid out.

By default, the last visible child of the split view will have this set, but it can be changed by explicitly setting fillHeight to true on another item.

The height of a split item with fillHeight set to true is still restricted within its https:// and https://.

See Also▲

See also https://, https://, https://, https://

SplitView.fillWidth : bool▲

This attached property controls whether the item takes the remaining space in the split view after all other items have been laid out.

By default, the last visible child of the split view will have this set, but it can be changed by explicitly setting fillWidth to true on another item.

The width of a split item with fillWidth set to true is still restricted within its https:// and https://.

See Also▲

See also https://, https://, https://, https://

SplitView.maximumHeight : real▲

This attached property controls the maximum height of the split item. The https:// is bound within the https:// and maximumHeight. A split item cannot be dragged to be larger than its maximumHeight.

The default value is Infinity. To reset this property to its default value, set it to undefined.

See Also▲

See also https://, https://, https://, https://

SplitView.maximumWidth : real▲

This attached property controls the maximum width of the split item. The https:// is bound within the https:// and maximumWidth. A split item cannot be dragged to be larger than its maximumWidth.

The default value is Infinity. To reset this property to its default value, set it to undefined.

See Also▲

See also https://, https://, https://, https://

SplitView.minimumHeight : real▲

This attached property controls the minimum height of the split item. The https:// is bound within the minimumHeight and https://. A split item cannot be dragged to be smaller than its minimumHeight.

The default value is 0. To reset this property to its default value, set it to undefined.

See Also▲

See also https://, https://, https://, https://

SplitView.minimumWidth : real▲

This attached property controls the minimum width of the split item. The https:// is bound within the minimumWidth and https://. A split item cannot be dragged to be smaller than its minimumWidth.

The default value is 0. To reset this property to its default value, set it to undefined.

See Also▲

See also https://, https://, https://, https://

SplitView.preferredHeight : real▲

This attached property controls the preferred height of the split item. The preferred height will be used as the size of the item, and will be bound within the https:// and https://. If the preferred height is not set, the item's https:// will be used.

When a split item is resized, the preferredHeight will be set in order to keep track of the new size.

By default, this property is not set, and therefore https:// will be used instead. To reset this property to its default value, set it to undefined.

Do not set the https:// property of a split item, as it will be overwritten upon each layout of the https://.

See Also▲

See also https://, https://, https://, https://

SplitView.preferredWidth : real▲

This attached property controls the preferred width of the split item. The preferred width will be used as the size of the item, and will be bound within the https:// and https://. If the preferred width is not set, the item's https:// will be used.

When a split item is resized, the preferredWidth will be set in order to keep track of the new size.

By default, this property is not set, and therefore https:// will be used instead. To reset this property to its default value, set it to undefined.

Do not set the https:// property of a split item, as it will be overwritten upon each layout of the https://.

See Also▲

See also https://, https://, https://, https://

SplitView.view : SplitView▲

This attached property holds the split view of the item it is attached to, or null if the item is not in a split view.

Method Documentation▲

 

bool restoreState(state)▲

Reads the preferred sizes from state and applies them to the split items.

Returns true if the state was successfully restored, otherwise false.

See Also▲

See also https://, https://()

var saveState()▲

Saves the preferred sizes of split items into a byte array and returns it.

See Also▲

See also https://, https://()

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+   

Ce document est disponible sous la licence https:// telle que publiée par la Free Software Foundation.