开发环境:Qt5.12.2 + QtCreator4.8.2
实现功能:版本号比较
示例代码:QVersionNumber
#include <QDebug> #include <QVersionNumber> int main() { QString version1 = "V01.00.0030"; QString version2 = "V01.00.0029"; QVersionNumber v1 = QVersionNumber::fromString(version1.mid(1)); // Remove the leading 'V' from version1 QVersionNumber v2 = QVersionNumber::fromString(version2.mid(1)); // Remove the leading 'V' from version2 if (v1 > v2)
{ qDebug() << version1 << "is greater than" << version2; }
else if (v1 < v2)
{ qDebug() << version1 << "is smaller than" << version2; }
else
{ qDebug() << version1 << "is equal to" << version2; } return 0; }
标签:QVersionNumber,version1,version2,版本号,v1,v2,比较,Qt From: https://www.cnblogs.com/yangjinghui/p/17514099.html