(1)函數QString::startsWith(),判斷某一個字符串是否以某個字符串開頭;該函數具有兩個參數,第一個參數制定了一個字符串,第二個參數指定是否大小寫敏感,默認大小寫敏感;
eg:
QString str = "Welcome to you !";
str.startsWith("Welcome",Qt::CaseSensitive);//return true
str.startsWith("you",Qt::CaseSensitive);//return false
(2)函數QString::endsWith()功能類似於QString::startsWith()。該函數判斷一個字符串是否以某個字符串結尾;
(3)函數QSting::contains() 判斷一個指定的字符串是否出現過,
QString str = "Welcome to you !";
str.contains("Welcome",Qt::CaseSensitive);
(4) 比較兩個字符串也是經常使用的功能
4.1 operator<(const QString&):比較一個字符串是否小於另一個字符串,如果是返回true;
4.2 operator<=(const QString&):比較一個字符串是否小於等於另一個字符串,如果是返回true;
4.3 operator==(const QString&):比較一個字符串是否等於另一個字符串,如果是返回true;
4.4 operator>=(const QString&):比較一個字符串是否大於等於另一個字符串,如果是返回true;
4.5 localAwareCompare (const QString&,const QString&):靜態函數,比較前后兩個字符串, 如果前面的小於后面,則返回負整數值,等於返回0;大於返回正整數;
4.6 compare(const QString& ,const QString&,Qt::CaseSensitivity):該函數可以指定是否進行大小寫的比較,而大小寫的比較是完全基於字符的Unicode編碼值的