Multi-Select/Highlight Calendar Cells



  • Hey guys,
    I would like the ability to be able to select more than one of my Calendar cells to save to batch save to a database, how could i go about this? my calendar is below:

            Calendar {
                id: calendar
                width: (parent.width > parent.height ? parent.width * 0.6 - parent.spacing : parent.width)
                height: (parent.height > parent.width ? parent.height * 0.6 - parent.spacing : parent.height)
                selectedDate: new Date()
                focus: true
    
    
               style: CalendarStyle {
    
    
                   dayOfWeekDelegate: Item {
                       height: dp(30)
                       width: parent.width
                       Rectangle {
                           height: parent.height
                           width: parent.width
                           anchors.fill: parent
                           border.color: "#00000000"
                           Label {
                               id: dayOfWeekDelegateText
                               text: Qt.locale().dayName(styleData.dayOfWeek, Locale.ShortFormat)
                               anchors.centerIn: parent
                               color: "black"
                           }
    
                       }
                   }
    
                   dayDelegate: Item {
                       readonly property color sameMonthDateTextColor: "#444"
                       readonly property color previousDateColor: "#444"
                       readonly property color selectedDateColor: "#20d5f0"
                       readonly property color selectedDateTextColor: "white"
                       readonly property color differentMonthDateTextColor: "#bbb"
                       readonly property color invalidDatecolor: "#dddddd"
    
                       Rectangle {
                           anchors.fill: parent
                           border.color: "#00000000"
                           color: styleData.date !== undefined && styleData.selected? selectedDateColor : "#00000000"
                           anchors.margins: styleData.selected ? -1 : 0
                       }
    
                       Label {
                           id: dayDelegateText
                           text: styleData.date.getDate()
                           anchors.centerIn: parent
                           color:  {
                               var color = invalidDatecolor;
                               if (styleData.valid) {
                                   color = styleData.visibleMonth ? sameMonthDateTextColor : differentMonthDateTextColor ;
                                   if (styleData.selected) {
                                       color = selectedDateTextColor;
                                   }
                               }
                               color ;
                            }
                        }
                    }
                }
            }
    

  • Qt Champions 2017

    more than one selection is not possible with calendar. For batch save you can use two different selection like fromDate and toDate.


Log in to reply
 

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