I am doing now with Calendar in QML , when describing it, there is a certain dayDelegate field, which describes what we will have as a square with a date.

In my case, I want the square to turn blue when I click on such a day and keep its color when closed, but when I do it all the squares turn blue.

How to fix a box with a date and change only its color, and not all?

  • Please add code to your question, otherwise no one will understand where your mistake is ... - E1mir

1 answer 1

First, you need to deal with the MVD pattern, and its implementation in QML, for this I recommend reading this article . The implementation of the color mark is essentially no different from the same list.

Secondly, the Calendar component is already losing its relevance today, since it relates to Qt Quick Controls of the first version, and recently the second one, which offers, for example, automatic scaling on screens with high pixel density. So, there is already used component MonthGrid.

Third, if you still need a Calendar, then when setting the delegate style, a table with auxiliary variables from the documentation for the dayDelegate property will help, which allow you to adjust the color depending on the conditions.