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

Version object

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Done
    • Not Evaluated
    • 5.4.0
    • 4.8.0
    • Core: Other
    • None

    Description

      Use case:
      Most application are using version numbers. To use them programatically you have to write a lot of code. Strange many programmers write a own class to handle this task, even it is very repetitive.

      But comparing of version numbers is a important task, which has to be done at many places in bigger applications. For example you have to compare version numbers of document formats etc. Or in network protocols compare the version numbers of the client and server.

      Feature Request:

      • Create QVersion, a data type which handles the common used x.y.z version numbers an is allowing to parse, serialize and compare them in many ways.
      • See the example solution above.

      Example solution:
      A custom class:

      class Version
      {
      public:
      Version();
      Version( int major, int minor, int revision );
      Version( const Version& copy );
      ~Version();
      const Version& operator=( const Version& assign );
      
      public:
      bool isValid() const;
      inline int major() const { return _major; }
      inline int minor() const { return _minor; }
      inline int revision() const { return _revision; }
      QString toString() const;
      static Version fromString( const QString& str );
      
      public: // Compare etc.
      bool operator==( const Version& compare ) const;
      bool operator!=( const Version& compare ) const;
      bool operator>( const Version& compare ) const;
      bool operator>=( const Version& compare ) const;
      bool operator<( const Version& compare ) const;
      bool operator<=( const Version& compare ) const;
      
      private:
      int _major;
      int _minor;
      int _revision;
      };
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Unassigned Unassigned
            qtcomsupport Qt Support
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes