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. How to update the current day of MonthGrid?
Forum Updated to NodeBB v4.3 + New Features

How to update the current day of MonthGrid?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 1 Posters 549 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.
  • H Offline
    H Offline
    Hit Tiger Tonight
    wrote on last edited by
    #1

    Hello guys,

    It is recommended to use the MonthGrid to implement a calendar or date picker in Qt6's document.

    I tried; it works generally. User can pick any date from the MonthGrid. But if change the system's date according to user's pick, the current day of MonthGrid is not changed.

    You know MonthGrid only has 'year' and 'month' properties, doesn't have a 'day' property. The only way is rewrite the delegate of MonthGrid, model has the 'day' property. But how to update the delegate?

    Borrow a picture from @Antonio Ortiz.MonthGrid wrong current index . Not related to this topic, just to make this post beautiful. Thanks.
    alt text

    H 1 Reply Last reply
    0
    • H Hit Tiger Tonight

      @Hit-Tiger-Tonight
      Here is a workaround:
      Once system time changed, call this function:

          function refreshYourMonthGrid() {
              theIDofYourMonthGrid.year++
              theIDofYourMonthGrid.year = thePickedDateFromMonthGrid.getFullYear()
          }
      
      H Offline
      H Offline
      Hit Tiger Tonight
      wrote on last edited by
      #3

      Even simpler:

          function refreshYourMonthGrid() {
              theIDofYourMonthGrid.year++
              theIDofYourMonthGrid.year--
          }
      
      1 Reply Last reply
      0
      • H Hit Tiger Tonight

        Hello guys,

        It is recommended to use the MonthGrid to implement a calendar or date picker in Qt6's document.

        I tried; it works generally. User can pick any date from the MonthGrid. But if change the system's date according to user's pick, the current day of MonthGrid is not changed.

        You know MonthGrid only has 'year' and 'month' properties, doesn't have a 'day' property. The only way is rewrite the delegate of MonthGrid, model has the 'day' property. But how to update the delegate?

        Borrow a picture from @Antonio Ortiz.MonthGrid wrong current index . Not related to this topic, just to make this post beautiful. Thanks.
        alt text

        H Offline
        H Offline
        Hit Tiger Tonight
        wrote on last edited by Hit Tiger Tonight
        #2

        @Hit-Tiger-Tonight
        Here is a workaround:
        Once system time changed, call this function:

            function refreshYourMonthGrid() {
                theIDofYourMonthGrid.year++
                theIDofYourMonthGrid.year = thePickedDateFromMonthGrid.getFullYear()
            }
        
        H 1 Reply Last reply
        0
        • H Hit Tiger Tonight

          @Hit-Tiger-Tonight
          Here is a workaround:
          Once system time changed, call this function:

              function refreshYourMonthGrid() {
                  theIDofYourMonthGrid.year++
                  theIDofYourMonthGrid.year = thePickedDateFromMonthGrid.getFullYear()
              }
          
          H Offline
          H Offline
          Hit Tiger Tonight
          wrote on last edited by
          #3

          Even simpler:

              function refreshYourMonthGrid() {
                  theIDofYourMonthGrid.year++
                  theIDofYourMonthGrid.year--
              }
          
          1 Reply Last reply
          0
          • H Hit Tiger Tonight referenced this topic on
          • H Hit Tiger Tonight has marked this topic as solved on

          • Login

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