Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDateTime::operator>=
Forum Updated to NodeBB v4.3 + New Features

QDateTime::operator>=

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 2.4k Views 1 Watching
  • 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.
  • C Offline
    C Offline
    Chrisw01
    wrote on last edited by
    #1

    Hi,

    Can someone point me to some examples of how to call QDateTime::operator>= . What I have is two QStrings, one with a date in it and one with a time in it. I want to compare those two variables to current date and time and execute code based upon results. I just can't seem to wrap my head around this.

    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Do you mean build a QDateTime using fromString and a QDateTime from a QTime::fromString and a QDate::currentDate and then compare them ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • C Offline
        C Offline
        Chrisw01
        wrote on last edited by
        #3

        Basically, I found this in the QT Docs.

        bool QDateTime::operator>=(const QDateTime &other) const

        Returns true if this datetime is later than or equal to the other datetime; otherwise returns false.

        I just cannot find any other documentation on how to use that,

        Thanks

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          It's just a bigger or equal operator:

          QDateTime time1 = QDateTime::fromString(myDateTimeString);
          QDateTime time2 = QDateTime::currentDateTime();
          
          if (time1 >= time2) {
              // Do some cool stuff
          }
          

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • C Offline
            C Offline
            Chrisw01
            wrote on last edited by
            #5

            Well, that makes sense, I thought it was a function to combine all the work into one line... derf...

            Thanks

            1 Reply Last reply
            0

            • Login

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