Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-72208

Qt.labs.calendar onClicked date is one day off.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.11.2
    • None
    • Windows

    Description

      I was working with the Qt.labs.calendar MonthGrid. When using the delegate I compared the model.day with the model.date.getDate() and they do not match. The onClicked returns the model.date from the current cell that was clicked which is wrong.
      Below is example code that compares the two objects.

                          Labs.MonthGrid{
                              id: monthGrid
                              Layout.fillWidth: true
                              Layout.fillHeight: true
                              month: model.month
                              year: model.year
                              locale: Qt.locale("en_US")
                              delegate: Column{Label{
                                      horizontalAlignment: Text.AlignHCenter
                                      verticalAlignment: Text.AlignVCenter
                                      opacity: model.month === monthGrid.month ? 1 : 0.5
                                      text: model.month +"/"+model.day+"/"+model.year
                                  }
                                  Label{
                                      horizontalAlignment: Text.AlignHCenter
                                      verticalAlignment: Text.AlignVCenter
                                      opacity: model.month === monthGrid.month ? 1 : 0.5
                                      text: model.date.getMonth()+"/"+model.date.getDate()+"/" +model.date.getYear()
                                  }                        
                                  Label{
                                      horizontalAlignment: Text.AlignHCenter
                                      verticalAlignment: Text.AlignVCenter
                                      text: model.day !== model.date.getDate() ? "Wrong Date":"Correct Date"
                                  }
                              }
                              onClicked: {
                                  console.log("onClicked date", date)
                              }
                              onPressAndHold: {
                                  console.log("onPressAndHold date", date)
                              }
                              onPressed: {
                                  console.log("onPressed date", date)
                              }
                              onReleased: {
                                  console.log("onReleased date", date)
                              }
                          }
      

      Attached is an image of the test program I was using. It compares the QtQuick.Controls 1.4 Calendar against one made with Qt.labs.calendar

      Attachments

        1. calendar.png
          calendar.png
          134 kB
        2. MonthGrid-OneOff.mov
          1.50 MB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            crashbug crashbug
            Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes