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 programmatically set invalid
Qt 6.11 is out! See what's new in the release blog

QDateTime programmatically set invalid

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 3 Posters 858 Views 3 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.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by
    #1

    I have a QDateTime member in a class, when the user changes state I would like to make this member invalid. I know I can achieve the same by other means, however if there is a way to change a member that is valid to invalid I would like to know.

    Kind Regards,
    Sy

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

      Hi

      Try to assign a default constructed one.

      QDateTime test = QDateTime();
      

      https://doc.qt.io/qt-5/qdatetime.html#QDateTime

      1 Reply Last reply
      5
      • S Offline
        S Offline
        StarterKit
        wrote on last edited by
        #3

        In python I did a.setDate(None) (where a was a QDateTime object) and a.isValid() returned False after it.
        Probably NULL in C may work either.

        SPlattenS 1 Reply Last reply
        0
        • S StarterKit

          In python I did a.setDate(None) (where a was a QDateTime object) and a.isValid() returned False after it.
          Probably NULL in C may work either.

          SPlattenS Offline
          SPlattenS Offline
          SPlatten
          wrote on last edited by
          #4

          @StarterKit , its not a pointer so NULL or nullptr will not work. Setting to QDateTime() does work.

          Kind Regards,
          Sy

          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