Lisha
Lisha

Reputation: 101

Shape for popup in qml

I want to create a popup as the root element and the shape of the popup is shown in the image(i.e. small triangle shape)

Popup with small triangle shape i.e. indicating the direction of the item that is the placement target

Do qml have any property where i can define this shape (if yes then how). If no then what is the best way to customize the shape of the popup. Also is it possible to use delegate and model property for popup (if yes then how)?

Upvotes: 1

Views: 1406

Answers (1)

Amfasis
Amfasis

Reputation: 4198

You can give a Popup a background:

Popup {
    background: Canvas {
        onPaint: {
            var ctx = getContext("2d")
            ctx.fillStyle = "white"
            ctx.beginPath()
            ctx.moveTo(0,10)
            ctx.lineTo(width * 0,5 - 10, 10)
            ctx.lineTo(width * 0,5, 0)
            ctx.lineTo(width * 0,5 + 10, 10)
            ctx.lineTo(width, 10)
            ctx.lineTo(width, height)
            ctx.lineTo(0, height)
            ctx.closePath()
            ctx.fill()
        }
    }
}

Upvotes: 4

Related Questions