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. Date and Time
Qt 6.11 is out! See what's new in the release blog

Date and Time

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 2 Posters 1.1k 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.
  • Bhushan_SureB Offline
    Bhushan_SureB Offline
    Bhushan_Sure
    wrote on last edited by
    #1

    How should i assign Time to Min and max of DateTimeAxis.
    I am able to get time by Qt.formatTime(new Date(),"hh:mm")
    But this is string, min and max are not taking this value.
    I want to assign Qt.formatTime(new Date(),"hh:mm") to min and
    max value should be 30 min more from current time.

    DateTimeAxis
            {
                id: x_axis
                tickCount: 4
                min:
                max:
            }
    
    J.HilkJ 1 Reply Last reply
    0
    • Bhushan_SureB Bhushan_Sure

      How should i assign Time to Min and max of DateTimeAxis.
      I am able to get time by Qt.formatTime(new Date(),"hh:mm")
      But this is string, min and max are not taking this value.
      I want to assign Qt.formatTime(new Date(),"hh:mm") to min and
      max value should be 30 min more from current time.

      DateTimeAxis
              {
                  id: x_axis
                  tickCount: 4
                  min:
                  max:
              }
      
      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Bhushan_Sure

      I can only guess, that you'll need a JS-Date object

      There's a date/QDate basic type
      http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#basic-qt-data-types
      but nothing for time

      so maybe this works? It's untested, I have only worked with c++ side of QtCharts module.

      DateTimeAxis
              {
                  id: x_axis
                  tickCount: 4
                  min: new Date(year, month, day, hours, minutes, seconds, milliseconds);
                  max: new Date(year, month, day, hours, minutes +30, seconds, milliseconds);
              }
      

      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      Bhushan_SureB 1 Reply Last reply
      1
      • J.HilkJ J.Hilk

        @Bhushan_Sure

        I can only guess, that you'll need a JS-Date object

        There's a date/QDate basic type
        http://doc.qt.io/qt-5/qtqml-cppintegration-data.html#basic-qt-data-types
        but nothing for time

        so maybe this works? It's untested, I have only worked with c++ side of QtCharts module.

        DateTimeAxis
                {
                    id: x_axis
                    tickCount: 4
                    min: new Date(year, month, day, hours, minutes, seconds, milliseconds);
                    max: new Date(year, month, day, hours, minutes +30, seconds, milliseconds);
                }
        
        Bhushan_SureB Offline
        Bhushan_SureB Offline
        Bhushan_Sure
        wrote on last edited by Bhushan_Sure
        #3

        @J.Hilk this is not working as it is saying that (year,month....) all these variables are not declared.

        How you used to define min and max in Qtcharts in C++ side ?

        J.HilkJ 1 Reply Last reply
        0
        • Bhushan_SureB Bhushan_Sure

          @J.Hilk this is not working as it is saying that (year,month....) all these variables are not declared.

          How you used to define min and max in Qtcharts in C++ side ?

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by
          #4

          @Bhushan_Sure said in Date and Time:

          @J.Hilk this is not working as it is saying that (year,month....) all these variables are not declared.

          How you used to define min and max in Qtcharts in C++ side ?

          Well, yes of course, that is the abstract syntax I posted, you would have to replace the placeholder names with actual numbers!


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          Bhushan_SureB 1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            @Bhushan_Sure said in Date and Time:

            @J.Hilk this is not working as it is saying that (year,month....) all these variables are not declared.

            How you used to define min and max in Qtcharts in C++ side ?

            Well, yes of course, that is the abstract syntax I posted, you would have to replace the placeholder names with actual numbers!

            Bhushan_SureB Offline
            Bhushan_SureB Offline
            Bhushan_Sure
            wrote on last edited by
            #5

            @J.Hilk i want current system time ? is there any function ? to get it so that i can assign it

            J.HilkJ 1 Reply Last reply
            0
            • Bhushan_SureB Bhushan_Sure

              @J.Hilk i want current system time ? is there any function ? to get it so that i can assign it

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @Bhushan_Sure

              afaik new Date() generates a new Date object containing the current date and time.


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              Bhushan_SureB 1 Reply Last reply
              2
              • J.HilkJ J.Hilk

                @Bhushan_Sure

                afaik new Date() generates a new Date object containing the current date and time.

                Bhushan_SureB Offline
                Bhushan_SureB Offline
                Bhushan_Sure
                wrote on last edited by Bhushan_Sure
                #7

                @J.Hilk

                DateTimeAxis {
                                    id: x_axis
                                    tickCount: 4
                                    format: "hh:mm"
                                    min:new Date(new Date() - 1800000)
                                    max: new Date()
                                }
                

                This Solved my problem.

                1 Reply Last reply
                1

                • Login

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