ClickableColor.qml 579 Bytes
Newer Older
1 2
import QtQuick 2.3
import QtQuick.Controls 1.2
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
import QtQuick.Dialogs 1.2

Rectangle {
    id:             _root
    width:          80
    height:         20
    border.width:   1
    border.color:   "black"

    signal colorSelected(var color)

    ColorDialog {
        id: colorDialog
        onAccepted: {
            _root.colorSelected(colorDialog.color)
            colorDialog.close()
        }
    }

    MouseArea {
        anchors.fill: parent

        onClicked: {
            colorDialog.color = _root.color
            colorDialog.visible = true
        }
    }
}