diff options
Diffstat (limited to 'examples/quick/painteditem/main.qml')
-rw-r--r-- | examples/quick/painteditem/main.qml | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/examples/quick/painteditem/main.qml b/examples/quick/painteditem/main.qml new file mode 100644 index 000000000..44be89dc3 --- /dev/null +++ b/examples/quick/painteditem/main.qml @@ -0,0 +1,77 @@ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +import QtQuick +import TextBalloonPlugin + +Item { + height: 480 + width: 320 + + //! [0] + ListModel { + id: balloonModel + ListElement { + balloonWidth: 200 + } + ListElement { + balloonWidth: 120 + } + } + + ListView { + anchors.bottom: controls.top + anchors.bottomMargin: 2 + anchors.top: parent.top + id: balloonView + delegate: TextBalloon { + anchors.right: index % 2 == 0 ? undefined : balloonView.contentItem.right + height: 60 + rightAligned: index % 2 == 0 ? false : true + width: balloonWidth + } + model: balloonModel + spacing: 5 + width: parent.width + } + //! [0] + + //! [1] + Rectangle { + id: controls + + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.margins: 1 + anchors.right: parent.right + border.width: 2 + color: "white" + height: parent.height * 0.15 + + Text { + anchors.centerIn: parent + text: "Add another balloon" + } + + MouseArea { + anchors.fill: parent + hoverEnabled: true + onClicked: { + balloonModel.append({ + "balloonWidth": Math.floor( + Math.random( + ) * 200 + 100) + }) + balloonView.positionViewAtIndex(balloonView.count - 1, + ListView.End) + } + onEntered: { + parent.color = "#8ac953" + } + onExited: { + parent.color = "white" + } + } + } + //! [1] +} |