Qml Calendar Style Data



  • I have a calendar control with a custom style. The style is defined in another file to keep things cleaner. The issue is that I need to somehow pass some data to the style if possible. This is an example of how I have it setup. The special dates is a list of date objects. If I include the style inline I can just access the data directly, but in a separate file I cannot. Is there any way to set my specialDates variable, or any other way to get the data in.

    Main.qml

    Calendar {
        id: calendar
        style: Style.calandarStyle
    }
    

    Style.qml

    property var calandarStyle: Component
    {
        CalendarStyle
        {
            property var specialDates;
    
            function isDateSpecial(date) {
                //This will return the status of the date
            }
           
            dayDelegate: Rectangle {
                Rectangle
                {
                    anchors.fill: parent
                    border.color: isDateSpecial(styleData.date) ? "black" : "transparent"
                    border.width: 1
                    Label
                    {
                        text: styleData.date.getDate()
                        anchors.centerIn: parent
                    }
                }
            }
        }
    }
    

Log in to reply
 

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