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

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

XMLWordPrintable

    • Windows
    • 57325020f (dev), 2e1337d87 (dev), 2e37850da (6.10), 7664d1d5a (6.9), dd8fddb19 (tqtc/lts-6.8), 60f0e4f5f (6.10), ab3781ee0 (6.9), 2462ea517 (tqtc/lts-6.8)

      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

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

            mitch_curtis Mitch Curtis
            crashbug crashbug
            Votes:
            4 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: