QString::compare 落日映苍穹つ 2022-04-13 14:30 366阅读 0赞 \[static\] int QString::compare(const QString &s1, const QString &s2, Qt::CaseSensitivity cs = Qt::CaseSensitive) Compares s1 with s2 and returns an integer less than, equal to, or greater than zero if s1 is less than, equal to, or greater than s2. If cs is Qt::CaseSensitive, the comparison is case sensitive; otherwise the comparison is case insensitive. Case sensitive comparison is based exclusively on the numeric Unicode([https://baike.so.com/doc/4443890-4652181.html)][https_baike.so.com_doc_4443890-4652181.html] values of the characters and is very fast, but is not what a human would expect. Consider sorting user-visible strings with localeAwareCompare(). int x = QString::compare(“aUtO”, “AuTo”, Qt::CaseInsensitive); // x == 0 int y = QString::compare(“auto”, “Car”, Qt::CaseSensitive); // y > 0 int z = QString::compare(“auto”, “Car”, Qt::CaseInsensitive); // z < 0 [https_baike.so.com_doc_4443890-4652181.html]: https://baike.so.com/doc/4443890-4652181.html%EF%BC%89
还没有评论,来说两句吧...