Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qml Calendar Style Data

Qml Calendar Style Data

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 926 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    krobinson
    wrote on last edited by
    #1

    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
                    }
                }
            }
        }
    }
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved