qml calendar component



  • In a qml calendar component I want to select and color only few days through selectData.date in dayDelegate.

    Ex. color: {(styleData.date==="2015-05-25") ? "yellow" : "red"}
    not work.

    How can I do this to work ?



  • what do you mean it doesn't work to select date or to display different color according to compare date ?

    here is to display different color. I think your delegate have not problem, so check your code.

    import QtQuick 1.0
    
    Item {
        id: main
        width: 1280; height: 720
        focus: true
    
        ListModel{
            id: mymodel
            ListElement { d: "2015-05-25" }
            ListElement { d: "2015-05-26" }
            ListElement { d: "2015-05-27" }
        }
    
        ListView {
            width: 100; height: 100*4
            focus: true
            model: mymodel
            delegate: Item {
                width: 100; height: 100
                Rectangle {
                    color: "black"
                    opacity: 0.5
                    Text {
                        text: d
                        color: d==="2015-05-25" ? "yellow" : "white"
                        anchors.centerIn: parent
                    }
                    anchors.fill: parent
                }
            }
            highlight: Rectangle {
                color: "red"
                opacity: 0.5
            }
        }
    }
    


  • I have solved the problem
    It works with

    styleData.date.toLocaleDateString() === "25 februarie 2015"



  • Hi,

    I suggest to use "numeric only" formats (for instance "yyyy-MM-dd"). In that case your app can work properly also in different Locales


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.